static void NodeTraverse()
        {
            LList list = new LList();

            list.Insert(6);
            list.Insert(8);
            list.Insert(12);

            Console.WriteLine($" does 8 exist: {list.Includes(8)}");
            Console.WriteLine($" does 6 exist: {list.Includes(6)}");
            Console.WriteLine($" does 12 exist: {list.Includes(8)}");

            list.Print();

            list.Append(16);
            list.Append(25);
            list.Append(30);

            Console.WriteLine($" does 30 exist: {list.Includes(30)}");


            list.InsertBefore(25, 53);
            list.InsertAfter(53, 31);

            list.Print();
        }
        /// <summary>
        /// Thhis is where the program starts
        /// </summary>
        static void startNode()
        {
            try
            {
                LList carlosList = new LList();
                Console.WriteLine("");
                Console.WriteLine("Starting with empty node");
                carlosList.Print();

                carlosList.Insert(77);
                carlosList.Insert(66);
                carlosList.Insert(55);
                carlosList.Insert(44);
                carlosList.Insert(33);
                Console.WriteLine("");
                Console.WriteLine("Linked List with Insert numbers 77,66,55,44.");
                carlosList.Print();

                Console.WriteLine("");
                Console.WriteLine($"Does 66 exsist {carlosList.Includes(66)}");
                Console.WriteLine($"Does 12 exsist {carlosList.Includes(12)}");

                carlosList.Append(88);
                carlosList.Append(99);
                Console.WriteLine("");
                Console.WriteLine("The appended linked list.  Appended 88,99.");
                carlosList.Print();

                carlosList.InsertBefore(66, 61);
                carlosList.InsertBefore(33, 31);
                Console.WriteLine("");
                Console.WriteLine("The InsertBefore Linked List.  Insert before 66, newValue 61.");
                Console.WriteLine("The InsertBefore Linked List.  Insert before 33, newValue 31."); //head of LL
                carlosList.Print();

                carlosList.InsertAfter(44, 49);
                carlosList.InsertAfter(31, 32);
                Console.WriteLine("");
                Console.WriteLine("The InsertAfter Linked List.  Insert after 44, newValue 49.");
                Console.WriteLine("The InsertAfter Linked List.  Insert after 31, newValue 32."); //head of LL
                carlosList.Print();

                Console.ReadLine();
            }
            catch (Exception error)
            {
                Console.WriteLine($"Oh no.  Error {error.Message}!!");
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");


            LList list = new LList();

            list.Insert(2);
            list.Insert(4);
            list.Insert(6);
            list.Insert(7);
            list.Insert(79);
            list.print();
            list.InsertAfter(6, 88);
            list.print();
            list.InsertBefore(6, 48);
            list.Append(43);
            list.print();
            Console.WriteLine("...............");
            int a = list.GetValue(9);
            int b = list.GetValue(0);
            int c = list.GetValue(4);

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
        }
        public static void Main(string[] args)
        {
            Node node1 = new Node(7);
            Node node2 = new Node("node2");
            Node node3 = new Node("node3");

            LList List = new LList(node1);

            List.Add(node2);
            List.Add(node3);

            Console.WriteLine("======= Original List =======");
            List.Print();

            Console.WriteLine("======= Node Appended to the End =======");
            Node node4 = new Node("node4");

            List.Append(node4);
            List.Print();

            Console.WriteLine("======= Node Added Before Node 4 =======");
            Node node5 = new Node("node5");

            List.AddBefore(node5, node4);
            List.Print();

            Console.WriteLine("======= Node Added After Node 5 =======");
            Node node6 = new Node("node6");

            List.AddAfter(node6, node5);
            List.Print();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            LList testLL = new LList(new Node(4));

            testLL.Append(new Node(21));
            Node newNode = new Node(5);

            testLL.AddBefore(newNode, 21);

            Console.WriteLine($"{testLL.Head.Value}");
        }
示例#6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Node node1 = new Node(7);
            Node node2 = new Node("cat");
            Node node3 = new Node(234);

            LList myAwesomeList = new LList(node1);

            myAwesomeList.Append(node2);

            myAwesomeList.Print();
        }
        static void Main(string[] args)
        {
            LList  list = new LList();
            Random rand = new Random();

            list.Insert(23);
            for (int i = 0; i < 10; i++)
            {
                if (i == 6)
                {
                    list.Insert(777);
                }

                list.Insert(rand.Next(50));
            }

            Console.WriteLine("The random link list was created.");

            Console.WriteLine($"\n\nThe list has a node containing 10: { list.Includes(10) }");
            Console.WriteLine($"The list has a node containing 23: { list.Includes(23) }");
            Console.WriteLine($"The list has a node containing 48: { list.Includes(48) }");

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Here is the linked list: ");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Inserted a random number before 777");
            list.InsertBefore(777, rand.Next(50));
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            Console.WriteLine("Inserted a random number after 777");
            list.InsertAfter(777, rand.Next(50));
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());

            Console.WriteLine("\n-------------------------------------------------------------------\n");
            list.Append(rand.Next(50));
            Console.WriteLine("Appended a random number to the end of the list");
            Console.WriteLine("Here is the updated list\n");
            Console.WriteLine(list.Print());



            Console.Write("\n\nPress any key to continue...");
            Console.ReadLine();
        }
示例#8
0
        static void NodeExample()
        {
            LList list = new LList();

            list.Insert(4);
            list.Insert(8);
            list.Insert(15);

            list.Print();

            list.Append(16);
            list.Append(23);
            list.Append(42);

            list.Print();

            list.InsertBefore(23, 53);

            list.InsertAfter(8, 3);
            list.InsertAfter(4, 1);


            list.Print();
        }
示例#9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            LList testLL = new LList(new Node(4));

            testLL.Append(new Node(21));
            Node newNode = new Node(5);

            testLL.AddBefore(newNode, 21);

            testLL.Print();



            int value = testLL.KthFromEnd(1);

            Console.WriteLine(value);
            Console.ReadKey();

            Console.WriteLine($"{testLL.Head.Value}");
        }
        /*
         * Console.WriteLine("Hello World!");
         * //instantiate a new list
         * LList list = new LList();
         * //using these values
         * int[] arrayofValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
         * for (int i =0; i < arrayofValues.Length; i++)
         * {
         *  list.Insert(arrayofValues[i]);
         * }*/

        static void NodeExample()
        {
            Node node = new Node(8);

            Console.WriteLine(node.Value);
            LList list = new LList();

            list.Insert(4);
            list.Insert(8);
            list.Insert(15);

            Console.WriteLine($"Does 8 exist?{list.Includes(8)}");
            Console.WriteLine($"Does 18 exist?{list.Includes(18)}");

            list.Append(10);

            list.InsertBefore(8, 22);

            list.InsertAfter(4, 33);

            list.Print();
        }