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();
        }
        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);
        }
Пример #3
0
        static void Main(string[] args)
        {
            LList list = new LList();

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

            Console.WriteLine(PosFrmEnd(list.Head, 3));
        }
        /// <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)
        {
            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();
        }
Пример #6
0
        static void PopulateList()
        {
            LList list = new LList(11);

            list.Insert(56);
            list.Insert(42);
            list.Insert(23);
            list.Insert(72);
            list.Insert(11);
            list.InsertBefore(42, 7);

            list.Print();

            Console.ReadLine();
        }
Пример #7
0
        static void Main(string[] args)
        {
            LList list = new LList();

            for (int i = 0; i < 15; i++)
            {
                list.Insert(i + 1);
            }
            Console.WriteLine(list.Print());
        }
Пример #8
0
        static void LinkedList()
        {
            LList <int> list = new LList <int>();

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

            Console.WriteLine("==============");
            Console.WriteLine(string.Join(',', list.Print()));


            LList <string> stringList = new LList <string>();

            stringList.Insert("cat");
            stringList.Insert("dog");
            stringList.Insert("bird");

            Console.WriteLine("STRINGS!");
            Console.WriteLine(string.Join(',', stringList.Print()));

            LList <Node <int> > nodeList = new LList <Node <int> >();



            //list.Print();
            //Console.WriteLine(list.Includes(55));

            //list.Append(16);

            //list.Print();

            //list.InsertBefore(16, 15);

            //list.Print();

            //list.InsertAfter(16, 23);
            //list.InsertAfter(4, 5);

            //list.Print();
        }
        /*
         * 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();
        }
Пример #10
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();
        }