public static void display(Node head) { Node start = head; while (start != null) { Console.Write(start.data + " "); start = start.next; } }
public static Node insert(Node current, int data) { Node node = new Node(data); Node saveHead = null; if (current == null) { current = node; current.next = null; saveHead = current; } else { saveHead = current; while (current.next != null) { current = current.next; } current.next = node; } return saveHead; }
public Node(int d) { data = d; next = null; }