Considering following definition of linked list data structure
class Node
{
public string Data = string.Empty;
public Node Next;
}
Write a function to randomly populate it with random data.
Answer:
class Node
{
public string Data = string.Empty;
public Node Next;
}
Write a function to randomly populate it with random data.
Answer:
static Node RandomList(int n)
{
if (n < = 0) return null;
Node N = new Node();
N.Data = n.ToString();
N.Next = RandomList(n - 1);
return N;
}