Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var l = new LinkedListClass();

            l.AddNode(new Node()
            {
                value = "1"
            });
            l.AddNode(new Node()
            {
                value = "2"
            });
            l.AddNode(new Node()
            {
                value = "3"
            });
            l.AddNode(new Node()
            {
                value = "4"
            });
            l.AddNode(new Node()
            {
                value = "5"
            });

            l.Print();

            l.Remove();

            l.Print();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            LinkedListClass list = new LinkedListClass();

            list.Add1(56);
            list.Add1(30);
            list.Add1(70);
            list.Display();
            list = new LinkedListClass();
            list.Add2(70);
            list.Add2(30);
            list.Add2(56);
            list.Display();
            list = new LinkedListClass();
            list.Add1(56);
            list.Add1(70);
            list.InsertAtParticularPosition(2, 30);
            list.Display();
            Console.WriteLine("First element popped out of the Linked List- " + list.RemoveFirstNode().data);
            list.Display();
            list.InsertAtParticularPosition(1, 56);
            list.Display();
            Console.WriteLine("Last element popped out of the Linked List- " + list.RemoveLastNode().data);
            list.Display();
            SortedLinkedListClass sortedLinkedList = new SortedLinkedListClass();

            sortedLinkedList.Add(56);
            sortedLinkedList.Add(30);
            sortedLinkedList.Add(40);
            sortedLinkedList.Add(70);
            Console.WriteLine("Sorted Linked List-");
            sortedLinkedList.Display();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Creating LinkedList of 5");


            LinkedListClass linkedList = new LinkedListClass();

            LinkedListClass.Node newNodeToadd = new LinkedListClass.Node(10);
            linkedList.AddNode(newNodeToadd);

            LinkedListClass.Node newNodeToadd2 = new LinkedListClass.Node(20);
            linkedList.AddNode(newNodeToadd2);

            LinkedListClass.Node newNodeToadd3 = new LinkedListClass.Node(-30);
            linkedList.AddNode(newNodeToadd3);

            LinkedListClass.Node newNodeToadd4 = new LinkedListClass.Node(40);
            linkedList.AddNode(newNodeToadd4);

            LinkedListClass.Node newNodeToadd5 = new LinkedListClass.Node(50);
            linkedList.AddNode(newNodeToadd5);

            Console.WriteLine("Total number of items in the list: " + linkedList.count);

            linkedList.PrintList();

            Console.WriteLine("deleting last item");

            linkedList.DeleteLastNode();

            Console.WriteLine("Total number of items in the list after deleting: " + linkedList.count);

            linkedList.AddAfterValue(30, new LinkedListClass.Node(35));

            linkedList.DeleteNode(35);
        }