Ejemplo n.º 1
0
 public static void display(Node head)
 {
     Node start = head;
     while (start != null)
     {
         Console.Write(start.data + " ");
         start = start.next;
     }
 }
Ejemplo n.º 2
0
        public static Node insert(Node head, int data)
        {
            Node p = new Node(data);

            if (head == null)
                head = p;
            else if (head.next == null)
                head.next = p;
            else
            {
                Node start = head;
                while (start.next != null)
                    start = start.next;
                start.next = p;
            }
            return head;
        }
Ejemplo n.º 3
0
        public static Node removeDuplicates(Node head)
        {
            Node start = head;
            while (start != null)
            {
                if (start.next != null && start.data == start.next.data)
                {
                    Node nextNext = start.next.next;
                    start.next = nextNext;
                }
                else
                {
                    start = start.next;
                }
                    
            }

            return head;
        }
Ejemplo n.º 4
0
 public Node(int d)
 {
     data = d;
     next = null;
 }