示例#1
0
 public static void display(Node head)
 {
     Node start = head;
     while (start != null)
     {
         Console.Write(start.data + " ");
         start = start.next;
     }
 }
示例#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;
        }
示例#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;
        }
示例#4
0
 public Node(int d)
 {
     data = d;
     next = null;
 }