Example #1
0
        public void Unorderd()
        {
            string text = File.ReadAllText(@"C:\Users\Admin\source\repos\Saurabh\DataStructure\LinkedList\inputText.txt", Encoding.UTF8);

            string[] stringSeparator = new string[] { " " };
            string[] textArray;
            textArray = text.Split(stringSeparator, StringSplitOptions.RemoveEmptyEntries);
            LinkList list = new LinkList();

            for (int i = textArray.Length - 1; i >= 0; i--)
            {
                list.InsertFront(textArray[i]);
            }
            list.DisplayStringList();
            Console.WriteLine("Enter a string which you want to be found:");
            string searchString = Console.ReadLine();

            if (list.Search(searchString))
            {
                list.DeleteKeyElement(searchString);
            }
            else
            {
                list.InsertFront(searchString);
            }
            string textFile = list.ReturnString();

            File.WriteAllText(@"C:\Users\Admin\source\repos\Saurabh\DataStructure\LinkedList\inputText.txt", textFile);
            // Console.WriteLine("Enter a string which you want to be add:");
            // string inputString = Console.ReadLine();
            // list.InsertNextTOKey(searchString,inputString);
            list.DisplayStringList();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Linked List !!");
            Console.WriteLine("\n");
            LinkList list = new LinkList();

            list.Append(56);
            list.Append(70);
            list.Insert(2, 30);
            list.Display();
            if (list.Search(30))
            {
                list.Insert(3, 40);
                Console.WriteLine("After Insertion :");
                list.Display();
            }
            else
            {
                Console.WriteLine("Node not Found !!");
            }
            list.Sort();
            Console.WriteLine("After Sorting :");
            list.Display();
            list.DeleteAnyNode(2);
            Console.WriteLine("After Deletion :");
            list.Display();
            Console.WriteLine("Size of Linked List : " + list.Size());
        }