Exemple #1
0
        public void Run()
        {
            LinkedListNode head = AssortedMethods.RandomLinkedList(10, 0, 10);

            Console.WriteLine(head.PrintForward());
            DeleteNode(head.Next.Next.Next.Next); // delete node 4
            Console.WriteLine(head.PrintForward());
        }
        public void Run()
        {
            var head = AssortedMethods.RandomLinkedList(10, 0, 10);

            Console.WriteLine(head.PrintForward());

            head = ReverseList(head);
            Console.WriteLine(head.PrintForward());
        }
        public void Run()
        {
            var head = AssortedMethods.RandomLinkedList(10, 0, 10);

            Console.WriteLine(head.PrintForward());

            var deleted = DeleteNode(head.Next.Next.Next.Next); // delete node 4

            Console.WriteLine("deleted? {0}", deleted);
            Console.WriteLine(head.PrintForward());
        }
Exemple #4
0
        public void Run()
        {
            LinkedListNode head = AssortedMethods.RandomLinkedList(10, 0, 10);

            Console.WriteLine(head.PrintForward());
            int nth = 3;
            //IntWrapper wr = new IntWrapper();
            LinkedListNode n = NthToLastR3(head, nth);

            NthToLastR1(head, nth);
            if (n != null)
            {
                Console.WriteLine(nth + "th to last node is " + n.Data);
            }
            else
            {
                Console.WriteLine("Null.  n is out of bounds.");
            }
        }
        public override void Run()
        {
            var head = AssortedMethods.RandomLinkedList(10, 0, 10);

            Console.WriteLine(head.PrintForward());
            const int nth = 3;

            var node = NthToLastR3(head, nth);

            NthToLastR1(head, nth);

            if (node != null)
            {
                Console.WriteLine(nth + "th to last node is " + node.Data);
            }
            else
            {
                Console.WriteLine("Null.  n is out of bounds.");
            }
        }