I was working on a singularly-linked list. While creating my own linked list I got confused on printing the collection of nodes in my custom linked list.
I want to know, does a singularly-linked list display its collection in a LIFO manner like a stack?
below is my Own LinkedList AND node is A Class can anyone tell me Does Singular LinkedList Prints The Collection In Lifo Manner.
class MYlinklist
{
Node header;
public void Add(int a)
{
Node n = new Node();
n.element = a;
n.Next = header;
header = n;
}
public void Print()
{
Node n = new Node();
n = header;
while (n != null)
{
Console.WriteLine(n.element.ToString());
n = n.Next;
}
}
}