Esempio n. 1
0
        static void Main(string[] args)
        {
            List <int> myList = new List <int>();

            myList.Append(1);
            myList.Append(2);
            myList.Append(3);
            Console.WriteLine(myList);

            myList = new List <int>(3, 2, 1);
            Console.WriteLine(myList);

            myList = new List <int>(new System.Collections.Generic.List <int>(new int[] { 4, 3, 2, 1 }));
            Console.WriteLine(myList);
            Console.WriteLine(myList.Length);
            Console.WriteLine(myList.Count());
            myList.AppendRange(new System.Collections.Generic.List <int>(new int[] { 4, 3, 2, 1 }));
            Console.WriteLine(myList);
            Console.WriteLine(myList.Length);
            Console.WriteLine(myList.Count());
            Console.WriteLine(myList.ElementAt(2));
            Console.WriteLine(myList.ElementAt(3));
            Console.WriteLine(myList.IndexOf(3));


            myList = new List <int>(10, 20, 30, 40);
            myList.Insert(0, 8);
            Console.WriteLine(myList);
            myList = new List <int>(10, 20, 30, 40);
            myList.Insert(1, 8);
            Console.WriteLine(myList);
            myList = new List <int>(10, 20, 30, 40);
            myList.Insert(2, 8);
            Console.WriteLine(myList);
            myList = new List <int>(10, 20, 30, 40);
            myList.Insert(4, 8);
            Console.WriteLine(myList);

            myList = new List <int>(10, 20, 30, 40);
            myList.Insert(3, 7, 8, 9);
            Console.WriteLine(myList);

            myList.Remove(7);
            Console.WriteLine(myList);
            myList.Remove(10);
            Console.WriteLine(myList);
            myList.Remove(40);
            Console.WriteLine(myList);
            myList.Remove(9);
            Console.WriteLine(myList);

            myList.RemoveAt(1);
            Console.WriteLine(myList);
            myList.RemoveAt(1);
            Console.WriteLine(myList);

            myList = new List <int>(10, 20, 30, 40);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);


            myList = new List <int>(2, 3, 1, 4);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);

            myList = new List <int>(4, 3, 2, 1);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);

            Random rand = new Random(); //static seed!

            for (int i = 0; i < 20; i++)
            {
                myList = new List <int>();
                for (int j = 0; j < i; j++)
                {
                    myList.Append(rand.Next() % 100);
                }
                Console.WriteLine(myList);
                myList.Sort();
                Console.WriteLine(myList);
                Console.WriteLine();
            }

            myList = new List <int>(4, 3, 2, 1);
            foreach (int item in myList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine(myList[0]);
            myList[1] = 8;
            Console.WriteLine(myList[1]);
            Console.WriteLine(myList[2]);
            Console.WriteLine(myList[3]);

            myList.RemoveAt(0);
            myList.RemoveAt(0);
            myList.RemoveAt(0);
            myList.RemoveAt(0);
            foreach (int item in myList)
            {
                Console.WriteLine(item);
            }

            Stack <int> myStack = new Stack <int>(1, 2, 3);

            Console.WriteLine(myStack);
            myStack.push(2);
            Console.WriteLine(myStack);
            Console.WriteLine(myStack.pop().ToString());
            Console.WriteLine(myStack);
            myStack.push(5);
            myStack.push(4);
            myStack.Sort();
            Console.WriteLine(myStack);

            Queue <int> myQueue = new Queue <int>(1, 2, 3);

            Console.WriteLine(myQueue);
            myQueue.enqueue(2);
            Console.WriteLine(myQueue);
            Console.WriteLine(myQueue.dequeue().ToString());
            Console.WriteLine(myQueue);
            myQueue.enqueue(5);
            myQueue.enqueue(4);
            myQueue.Sort();
            Console.WriteLine(myQueue);

            foreach (int item in myQueue)
            {
                Console.Write(item);
            }
            Console.WriteLine();

            System.Collections.Generic.List <int> theirList = new System.Collections.Generic.List <int>();
            theirList.Add(1);
            theirList.Add(1);
            theirList.Add(1);
            theirList.Add(1);

            var exit = Console.Read(); //DEBUG pause
        }
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {
                    Console.WriteLine("\n\n\n--------DATA STRUCTURES MENU--------");
                    Console.WriteLine("1. Linked List");
                    Console.WriteLine("2. Stack");
                    Console.WriteLine("3. Queue");
                    Console.WriteLine("4. Exit");
                    Console.WriteLine("\nEnter Your Choice : ");
                    int choice = Convert.ToInt32(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                    {
                        LinkedList myList = new LinkedList();
                        int        flag   = 0;
                        while (flag == 0)
                        {
                            Console.WriteLine("\n\n\n------LINKED LIST MENU--------");
                            Console.WriteLine("1. Add Element");
                            Console.WriteLine("2. Remove Element");
                            Console.WriteLine("3. Sort Linked List");
                            Console.WriteLine("4. Display Linked List");
                            Console.WriteLine("5. Exit");
                            Console.WriteLine("\nEnter Your Choice : ");
                            int linkedListOperationChoice = Convert.ToInt32(Console.ReadLine());

                            switch (linkedListOperationChoice)
                            {
                            case 1:
                            {
                                Console.WriteLine("Enter The Position Where You Want to Insert The Data : ");
                                int position = Convert.ToInt32(Console.ReadLine());
                                Console.WriteLine("Enter the data : ");
                                int data = Convert.ToInt32(Console.ReadLine());
                                myList.Add(data, position);
                                myList.Display();
                                break;
                            }

                            case 2:
                            {
                                Console.WriteLine("Enter The Position Of The Data Which You Want To Delete : ");
                                int position = Convert.ToInt32(Console.ReadLine());
                                int data     = myList.Remove(position);
                                myList.Display();
                                break;
                            }

                            case 3:
                            {
                                myList.Sort();
                                Console.WriteLine("\nSorted Linked List");
                                myList.Display();
                                break;
                            }

                            case 4:
                            {
                                myList.Display();
                                break;
                            }

                            case 5:
                            {
                                flag = 1;
                                break;
                            }

                            default:
                            {
                                Console.WriteLine("Invalid Choice Entered");
                                break;
                            }
                            }
                        }
                        break;
                    }

                    case 2:
                    {
                        Stack myStack = new Stack();
                        int   flag    = 0;
                        while (flag == 0)
                        {
                            Console.WriteLine("\n\n\n------STACK MENU------");
                            Console.WriteLine("1. Push Element");
                            Console.WriteLine("2. Pop Element");
                            Console.WriteLine("3. Sort Stack");
                            Console.WriteLine("4. Get Top Element");
                            Console.WriteLine("5. Display Stack");
                            Console.WriteLine("6. Exit");
                            Console.WriteLine("\nEnter Your Choice : ");
                            int stackOperationChoice = Convert.ToInt32(Console.ReadLine());

                            switch (stackOperationChoice)
                            {
                            case 1:
                            {
                                Console.WriteLine("Enter the data : ");
                                int data = Convert.ToInt32(Console.ReadLine());
                                myStack.Add(data);
                                myStack.Display();
                                break;
                            }

                            case 2:
                            {
                                int data = myStack.Remove();
                                myStack.Display();
                                break;
                            }

                            case 3:
                            {
                                myStack.Sort();
                                Console.WriteLine("\nAfter Sorting");
                                myStack.Display();
                                break;
                            }

                            case 4:
                            {
                                int data = myStack.GetElement();
                                if (data != -1)
                                {
                                    Console.WriteLine("TOP ELEMENT IS : {0}", data);
                                }
                                break;
                            }

                            case 5:
                            {
                                myStack.Display();
                                break;
                            }

                            case 6:
                            {
                                flag = 1;
                                break;
                            }

                            default:
                            {
                                Console.WriteLine("Invalid Choice Entered");
                                break;
                            }
                            }
                        }
                        break;
                    }

                    case 3:
                    {
                        Queue myQueue = new Queue();
                        int   flag    = 0;
                        while (flag == 0)
                        {
                            Console.WriteLine("\n\n\n------QUEUE MENU------");
                            Console.WriteLine("1. Enqueue");
                            Console.WriteLine("2. Dequeue");
                            Console.WriteLine("3. Sort Queue");
                            Console.WriteLine("4. Peak");
                            Console.WriteLine("5. Display Queue");
                            Console.WriteLine("6. Exit");
                            Console.WriteLine("\nEnter Your Choice : ");
                            int queueOperationChoice = Convert.ToInt32(Console.ReadLine());

                            switch (queueOperationChoice)
                            {
                            case 1:
                            {
                                Console.WriteLine("\nEnter the data : ");
                                int data = Convert.ToInt32(Console.ReadLine());
                                myQueue.Add(data);
                                myQueue.Display();
                                break;
                            }

                            case 2:
                            {
                                int data = myQueue.Remove();
                                if (data != -1)
                                {
                                    Console.WriteLine("\n{0} IS DELETED.", data);
                                    myQueue.Display();
                                }
                                break;
                            }

                            case 3:
                            {
                                myQueue.Sort();
                                Console.WriteLine("\nAFTER SORTING:");
                                myQueue.Display();
                                break;
                            }

                            case 4:
                            {
                                int data = myQueue.Peak();
                                if (data != -1)
                                {
                                    Console.WriteLine("The First Element Is : {0} ", data);
                                }
                                break;
                            }

                            case 5:
                            {
                                myQueue.Display();
                                break;
                            }

                            case 6:
                            {
                                flag = 1;
                                break;
                            }

                            default:
                            {
                                Console.WriteLine("Invalid Choice Entered");
                                break;
                            }
                            }
                        }
                        break;
                    }

                    case 4:
                    {
                        Environment.Exit(0);
                        break;
                    }

                    default:
                    {
                        Console.WriteLine("Invalid Choice Entered");
                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Program Terminated Due To The Following Exception : {0}", e.Message);
                Console.ReadKey();
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            int choice;
            int innerChoice = 0;

            Console.WriteLine("------------------------Data Structures--------------------------");
            Console.WriteLine("1. Stack");
            Console.WriteLine("2. Queue");
            Console.WriteLine("3. Linked List");
            int.TryParse(Console.ReadLine(), out choice);
            switch (choice)
            {
            case 1:
                Stack stack = new Stack();
                while (true)
                {
                    Console.WriteLine("1. Add");
                    Console.WriteLine("2. Remove");
                    Console.WriteLine("3. Display");
                    Console.WriteLine("4. Sort");
                    Console.WriteLine("5. Get Top Value");
                    Console.WriteLine("6. Exit from Stack");

                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        Console.WriteLine("Enter Element to be Inserted");
                        stack.Add(int.Parse(Console.ReadLine()));
                        break;

                    case 2:
                        Console.WriteLine("Removed " + stack.Remove() + " from the top of the stack");
                        break;

                    case 3:
                        stack.Display();
                        break;

                    case 4:
                        stack.Sort();
                        Console.WriteLine("Sorted Stack");
                        stack.Display();
                        break;

                    case 5:
                        Console.WriteLine("The Top Value of Stack=" + stack.GetTop());
                        break;

                    case 6:
                        innerChoice = 1;
                        break;

                    default:
                        Console.WriteLine("Wrong Choice");
                        break;
                    }
                    if (innerChoice == 1)
                    {
                        innerChoice = 0;
                        break;
                    }
                }
                break;

            case 2:
                Queue queue = new Queue();
                while (true)
                {
                    Console.WriteLine("1. Add");
                    Console.WriteLine("2. Remove");
                    Console.WriteLine("3. Display");
                    Console.WriteLine("4. Sort");
                    Console.WriteLine("5. Peek");
                    Console.WriteLine("6. Check Queue is Full");
                    Console.WriteLine("7. Check Queue is Empty");
                    Console.WriteLine("8. Exit from Queue");
                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        Console.WriteLine("Enter Element to be Inserted");
                        queue.Add(int.Parse(Console.ReadLine()));
                        Console.WriteLine("Data Inserted");
                        break;

                    case 2:
                        Console.WriteLine("Removed " + queue.Remove() + " from the front of the queue");
                        break;

                    case 3:
                        queue.Display();
                        break;

                    case 4:
                        queue.Sort();
                        Console.WriteLine("Sorted Queue");
                        queue.Display();
                        break;

                    case 5:
                        Console.WriteLine("The Front Value of Queue=" + queue.Peek());
                        break;

                    case 6:
                        if (queue.IsFull())
                        {
                            Console.WriteLine("Queue is full");
                        }
                        else
                        {
                            Console.WriteLine("Queue is not full");
                        }
                        break;

                    case 7:
                        if (queue.IsEmpty())
                        {
                            Console.WriteLine("Queue is empty");
                        }
                        else
                        {
                            Console.WriteLine("Queue is not empty");
                        }
                        break;

                    case 8:
                        innerChoice = 1;
                        break;

                    default:
                        Console.WriteLine("Wrong Choice");
                        break;
                    }

                    if (innerChoice == 1)
                    {
                        innerChoice = 0;
                        break;
                    }
                }
                break;

            case 3:
                LinkedList linkedList = new LinkedList();
                while (true)
                {
                    Console.WriteLine("1. Add");
                    Console.WriteLine("2. Remove");
                    Console.WriteLine("3. Display");
                    Console.WriteLine("4. Sort");
                    Console.WriteLine("5. Insert at specific location");
                    Console.WriteLine("6. Remove from specific location");
                    Console.WriteLine("7. Exit from Queue");
                    choice = int.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        Console.WriteLine("Enter Element to be Inserted");
                        linkedList.Add(int.Parse(Console.ReadLine()));
                        Console.WriteLine("Data Inserted");
                        break;

                    case 2:
                        Console.WriteLine("Removed " + linkedList.Remove() + " from the linked list");
                        break;

                    case 3:
                        linkedList.Display();
                        break;

                    case 4:
                        linkedList.Sort();
                        Console.WriteLine("Sorted Linked List");
                        linkedList.Display();
                        break;

                    case 5:
                        Console.WriteLine("Enter Data");
                        int requestData = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter Index");
                        int index = int.Parse(Console.ReadLine());
                        linkedList.AddDataAtPosition(requestData, index);
                        Console.WriteLine("Data Inserted");
                        break;

                    case 6:
                        Console.WriteLine("Enter Index");
                        int responseData = linkedList.RemoveAtIndex(int.Parse(Console.ReadLine()));
                        Console.WriteLine("Data Removed");
                        break;

                    case 7:
                        innerChoice = 1;
                        break;

                    default:
                        Console.WriteLine("Wrong Choice");
                        break;
                    }

                    if (innerChoice == 1)
                    {
                        innerChoice = 0;
                        break;
                    }
                }
                break;

            default:
                break;
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            List<int> myList = new List<int>();
            myList.Append(1);
            myList.Append(2);
            myList.Append(3);
            Console.WriteLine(myList);

            myList = new List<int>(3, 2, 1);
            Console.WriteLine(myList);

            myList = new List<int>(new System.Collections.Generic.List<int>(new int[] { 4, 3, 2, 1 }));
            Console.WriteLine(myList);
            Console.WriteLine(myList.Length);
            Console.WriteLine(myList.Count());
            myList.AppendRange(new System.Collections.Generic.List<int>(new int[] { 4, 3, 2, 1 }));
            Console.WriteLine(myList);
            Console.WriteLine(myList.Length);
            Console.WriteLine(myList.Count());
            Console.WriteLine(myList.ElementAt(2));
            Console.WriteLine(myList.ElementAt(3));
            Console.WriteLine(myList.IndexOf(3));

            myList = new List<int>(10, 20, 30, 40);
            myList.Insert(0, 8);
            Console.WriteLine(myList);
            myList = new List<int>(10, 20, 30, 40);
            myList.Insert(1, 8);
            Console.WriteLine(myList);
            myList = new List<int>(10, 20, 30, 40);
            myList.Insert(2, 8);
            Console.WriteLine(myList);
            myList = new List<int>(10, 20, 30, 40);
            myList.Insert(4, 8);
            Console.WriteLine(myList);

            myList = new List<int>(10, 20, 30, 40);
            myList.Insert(3, 7, 8, 9);
            Console.WriteLine(myList);

            myList.Remove(7);
            Console.WriteLine(myList);
            myList.Remove(10);
            Console.WriteLine(myList);
            myList.Remove(40);
            Console.WriteLine(myList);
            myList.Remove(9);
            Console.WriteLine(myList);

            myList.RemoveAt(1);
            Console.WriteLine(myList);
            myList.RemoveAt(1);
            Console.WriteLine(myList);

            myList = new List<int>(10, 20, 30, 40);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);

            myList = new List<int>(2, 3, 1, 4);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);

            myList = new List<int>(4, 3, 2, 1);
            Console.WriteLine(myList);
            myList.Sort();
            Console.WriteLine(myList);

            Random rand = new Random(); //static seed!
            for (int i = 0; i < 20; i++)
            {
                myList = new List<int>();
                for (int j = 0; j < i; j++)
                    myList.Append(rand.Next() % 100);
                Console.WriteLine(myList);
                myList.Sort();
                Console.WriteLine(myList);
                Console.WriteLine();
            }

            myList = new List<int>(4, 3, 2, 1);
            foreach (int item in myList)
                Console.WriteLine(item);

            Console.WriteLine(myList[0]);
            myList[1] = 8;
            Console.WriteLine(myList[1]);
            Console.WriteLine(myList[2]);
            Console.WriteLine(myList[3]);

            myList.RemoveAt(0);
            myList.RemoveAt(0);
            myList.RemoveAt(0);
            myList.RemoveAt(0);
            foreach (int item in myList)
                Console.WriteLine(item);

            Stack<int> myStack = new Stack<int>(1, 2, 3);
            Console.WriteLine(myStack);
            myStack.push(2);
            Console.WriteLine(myStack);
            Console.WriteLine(myStack.pop().ToString());
            Console.WriteLine(myStack);
            myStack.push(5);
            myStack.push(4);
            myStack.Sort();
            Console.WriteLine(myStack);

            Queue<int> myQueue = new Queue<int>(1, 2, 3);
            Console.WriteLine(myQueue);
            myQueue.enqueue(2);
            Console.WriteLine(myQueue);
            Console.WriteLine(myQueue.dequeue().ToString());
            Console.WriteLine(myQueue);
            myQueue.enqueue(5);
            myQueue.enqueue(4);
            myQueue.Sort();
            Console.WriteLine(myQueue);

            foreach (int item in myQueue)
            {
                Console.Write(item);
            }
            Console.WriteLine();

            System.Collections.Generic.List<int> theirList = new System.Collections.Generic.List<int>();
            theirList.Add(1);
            theirList.Add(1);
            theirList.Add(1);
            theirList.Add(1);

            var exit = Console.Read(); //DEBUG pause
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("\n\n\n--------DATA STRUCTURES MENU--------");
                Console.WriteLine("1. Linked List");
                Console.WriteLine("2. Stack");
                Console.WriteLine("3. Queue");
                Console.WriteLine("4. Exit");
                Console.WriteLine("Enter Your Choice : ");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                {
                    LinkedList myList = new LinkedList();
                    int        flag   = 0;
                    while (flag == 0)
                    {
                        Console.WriteLine("\n\n\n------LINKED LIST MENU--------");
                        Console.WriteLine("1. Add Element");
                        Console.WriteLine("2. Remove Element");
                        Console.WriteLine("3. Sort Linked List");
                        Console.WriteLine("4. Display Linked List");
                        Console.WriteLine("5. Exit");
                        Console.WriteLine("Enter Your Choice : ");
                        int linkedListOperationChoice = Convert.ToInt32(Console.ReadLine());

                        switch (linkedListOperationChoice)
                        {
                        case 1:
                        {
                            Console.WriteLine("Enter The Position Where You Want to Insert The Data : ");
                            int position = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("Enter the data : ");
                            int data = Convert.ToInt32(Console.ReadLine());
                            myList.Add(data, position);
                            break;
                        }

                        case 2:
                        {
                            Console.WriteLine("Enter The Position Where You Want to Insert The Data : ");
                            int position = Convert.ToInt32(Console.ReadLine());
                            int data     = myList.Remove();
                            break;
                        }

                        case 3:
                        {
                            myList.Sort();
                            Console.WriteLine("Sorted Linked List");
                            myList.Display();
                            break;
                        }

                        case 4:
                        {
                            myList.Display();
                            break;
                        }

                        case 5:
                        {
                            flag = 1;
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("Invalid Choice Entered");
                            break;
                        }
                        }
                    }
                    break;
                }

                case 2:
                {
                    Stack myStack = new Stack();
                    int   flag    = 0;
                    while (flag == 0)
                    {
                        Console.WriteLine("\n\n\n------STACK MENU------");
                        Console.WriteLine("1. Push Element");
                        Console.WriteLine("2. Pop Element");
                        Console.WriteLine("3. Sort Stack");
                        Console.WriteLine("4. Display Stack");
                        Console.WriteLine("5. Exit");
                        Console.WriteLine("Enter Your Choice : ");
                        int stackOperationChoice = Convert.ToInt32(Console.ReadLine());

                        switch (stackOperationChoice)
                        {
                        case 1:
                        {
                            Console.WriteLine("Enter the data : ");
                            int data = Convert.ToInt32(Console.ReadLine());
                            myStack.Add(data);
                            break;
                        }

                        case 2:
                        {
                            int position = Convert.ToInt32(Console.ReadLine());
                            int data     = myStack.Remove();
                            break;
                        }

                        case 3:
                        {
                            myStack.Sort();
                            Console.WriteLine("Sorted Stack");
                            myStack.Display();
                            break;
                        }

                        case 4:
                        {
                            myStack.Display();
                            break;
                        }

                        case 5:
                        {
                            flag = 1;
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("Invalid Choice Entered");
                            break;
                        }
                        }
                    }
                    break;
                }

                case 3:
                {
                    Queue myQueue = new Queue();
                    int   flag    = 0;
                    while (flag == 0)
                    {
                        Console.WriteLine("\n\n\n------QUEUE MENU------");
                        Console.WriteLine("1. Enqueue");
                        Console.WriteLine("2. Dequeue");
                        Console.WriteLine("3. Sort Queue");
                        Console.WriteLine("4. Display Queue");
                        Console.WriteLine("5. Exit");
                        Console.WriteLine("Enter Your Choice : ");
                        int queueOperationChoice = Convert.ToInt32(Console.ReadLine());

                        switch (queueOperationChoice)
                        {
                        case 1:
                        {
                            Console.WriteLine("Enter the data : ");
                            int data = Convert.ToInt32(Console.ReadLine());
                            myQueue.Add(data);
                            break;
                        }

                        case 2:
                        {
                            int position = Convert.ToInt32(Console.ReadLine());
                            int data     = myQueue.Remove();
                            break;
                        }

                        case 3:
                        {
                            myQueue.Sort();
                            Console.WriteLine("Sorted Stack");
                            myQueue.Display();
                            break;
                        }

                        case 4:
                        {
                            myQueue.Display();
                            break;
                        }

                        case 5:
                        {
                            flag = 1;
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("Invalid Choice Entered");
                            break;
                        }
                        }
                    }
                    break;
                }

                case 4:
                {
                    Environment.Exit(0);
                    break;
                }

                default:
                {
                    Console.WriteLine("Invalid Choice Entered");
                    break;
                }
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            bool result       = true;
            bool secondChoice = true;
            int  rs;

            while (result)
            {
                Console.WriteLine("Which Operation you want to operate :\n1 for Stack \n2 for Queue\n3 for Link List");
                int op = Convert.ToInt32(Console.ReadLine());
                switch (op)
                {
                case 1:
                    Stack myStack = new Stack();
                    while (secondChoice)
                    {
                        Console.WriteLine("\n1 for Add a number \n2 for Delete top element from stack\n3 for Sorting\n4 for Top Value\n5 for Display the Stack");
                        op = Convert.ToInt32(Console.ReadLine());
                        switch (op)
                        {
                        case 1:
                            Console.WriteLine("Enter Element to be Added");
                            myStack.Add(Convert.ToInt32(Console.ReadLine()));
                            break;

                        case 2:
                            rs = myStack.Display();
                            if (rs == -1)
                            {
                                break;
                            }
                            myStack.Delete();
                            myStack.Display();
                            break;

                        case 3:
                            myStack.Sort();
                            myStack.Display();
                            break;

                        case 4:
                            //myStack.Peek();
                            int topElement = myStack.TopValue();
                            Console.WriteLine("Top Element in stack : {0}", topElement);
                            break;

                        case 5:
                            myStack.Display();
                            break;
                        }
                        Console.WriteLine("Do you want to continue : Y or N");
                        if (((Console.ReadLine()).ToUpper()).Equals("N"))
                        {
                            secondChoice = false;
                        }
                    }
                    break;

                case 2:
                    Queue myQueue = new Queue();
                    while (secondChoice)
                    {
                        Console.WriteLine("\n1 for Add a number \n2 for Delete element from Queue\n3 for Sorting\n4 for Peek Value\n5 for Display the Queue \n6 To check Queue Full\n7 To check Queue is empty");
                        op = Convert.ToInt32(Console.ReadLine());
                        switch (op)
                        {
                        case 1:
                            Console.WriteLine("Enter Element to be Added");
                            myQueue.Add(Convert.ToInt32(Console.ReadLine()));
                            break;

                        case 2:
                            rs = myQueue.Display();
                            if (rs == -1)
                            {
                                break;
                            }
                            myQueue.Delete();
                            rs = myQueue.Display();
                            break;

                        case 3:
                            myQueue.Sort();
                            myQueue.Display();
                            break;

                        case 4:
                            int first = myQueue.Peek();
                            Console.WriteLine("Peek Value in Queue is : {0}", first);
                            break;

                        case 5:
                            myQueue.Display();
                            break;

                        case 6:
                            if (myQueue.isEmpty())
                            {
                                Console.WriteLine("Queue is Empty");
                            }
                            else
                            {
                                Console.WriteLine("Queue is full");
                            }
                            break;

                        case 7:
                            if (myQueue.isFull())
                            {
                                Console.WriteLine("Queue is full");
                            }
                            else
                            {
                                Console.WriteLine("Queue is Empty");
                            }
                            break;
                        }
                        Console.WriteLine("Do you want to continue : Y or N");
                        if (((Console.ReadLine()).ToUpper()).Equals("Y"))
                        {
                            secondChoice = true;
                        }
                        else
                        {
                            secondChoice = false;
                        }
                    }

                    break;

                case 3:
                    LinkList myList = new LinkList();
                    while (secondChoice)
                    {
                        Console.WriteLine("\n1 For Add a number \n2 for Delete element from LinkList\n3 for Sorting\n4 To Insert at the specific position\n5 for Display the LinkList \n6 To Remove from the specific position and adjust list");
                        op = Convert.ToInt32(Console.ReadLine());
                        switch (op)
                        {
                        case 1:
                            Console.WriteLine("Enter Element to be Added");
                            myList.Add(Convert.ToInt32(Console.ReadLine()));
                            break;

                        case 2:

                            myList.Delete();

                            break;

                        case 3:
                            myList.Sort();
                            myList.Display();
                            break;

                        case 4:
                            Console.WriteLine("Enter the Data You want to insert ");
                            int insert = Convert.ToInt32(Console.ReadLine());
                            Console.WriteLine("Enter the index where you want to insert ");
                            int index = Convert.ToInt32(Console.ReadLine());
                            myList.InsertAtIndex(insert, index);
                            break;

                        case 5:
                            rs = myList.Display();
                            break;

                        case 6:
                            Console.WriteLine("Enter the index where you want to delete the data from ");
                            int delete = Convert.ToInt32(Console.ReadLine());
                            myList.RemoveAtIndex(delete);
                            break;
                        }
                        Console.WriteLine("Do you want to continue : Y or N");
                        if (((Console.ReadLine()).ToUpper()).Equals("Y"))
                        {
                            secondChoice = true;
                        }
                        else
                        {
                            secondChoice = false;
                        }
                    }
                    break;

                default:
                    break;
                }
                Console.WriteLine("Do you want to continue : Y or N");
                if (((Console.ReadLine()).ToUpper()).Equals("Y"))
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }


            Console.ReadKey();
        }