Exemplo n.º 1
0
        public void runList()
        {
            //LinkedList
            LinkedList llist = new LinkedList();

            // Insert 6. So linked list becomes 6->NUllist
            llist.append(6);

            // Insert 7 at the beginning.
            // So linked list becomes 7->6->NUllist
            llist.push(7);

            // Insert 1 at the beginning.
            // So linked list becomes 1->7->6->NUllist
            llist.push(1);

            // Insert 4 at the end. So linked list becomes
            // 1->7->6->4->NUllist
            llist.append(4);

            // Insert 8, after 7. So linked list becomes
            // 1->7->8->6->4->NUllist
            llist.insertAfter(llist.head.next, 8);

            Console.Write("Created Linked list is: ");
            llist.printList();

            llist.ReverseList();
            Console.WriteLine("\nReversed Linked list:");
            llist.printList();

            // Delete node with data 1
            llist.deleteNode(1);
            Console.WriteLine("\nLinked List after Deletion of 1:");
            llist.printList();

            Console.ReadLine();
        }