Example #1
0
        static void Main(string[] args)
        {
            int[] unsortedArray = new int[] { 22, 3, 1, -20, 45, 67, -100, 34 };
            // int[] unsortedArray = new int[] {20,35,-15,7,55,1,-22};

            PrintArray("Bubble Sort", BubbleSort.Sort(unsortedArray));
            PrintArray("Bubble Sort Optimized", BubbleSort.SortOptimized(unsortedArray));
            PrintArray("Merge Sort", MergeSort.Sort(unsortedArray));

            // RunBubbleSort(unsortedArray);
            // RunSelectionSort(unsortedArray);
            // RunInsertionSort(unsortedArray);
            // RunShellSort(unsortedArray);
        }
Example #2
0
        static void Main(string[] args)
        {
            #region Merge Sort

            MergeSort mergeSort = new MergeSort();
            int[]     result    = mergeSort.Sort(new int[] { 2, 8, 4, 6, 10, 20, 1, 5, 0 });
            for (int i = 0; i < result.Length; i++)
            {
                Console.Write(result[i] + " ");
            }


            #endregion


            #region Fibonacci

            //Fibonacci fib = new Fibonacci();
            //fib.FiboViaRecursion(55);
            //fib.FiboViaIterative(55);

            #endregion

            #region Factorial
            //// Calling the factorial function
            //Factorial factorial = new Recursion.Factorial();
            ////Calculating factorial using recursion function
            //Console.WriteLine("Factorial Via Recursion " + factorial.FactorialViaRecursion(6));

            //// Calculating factorial using the iterative function
            //Console.WriteLine("Factorial Via Iterative " + factorial.FactorialViaIterative(6));
            #endregion

            //Array Rotation Object Initialization and calling with input
            //ArrayRotation rotation = new ArrayRotation();
            //int[] inputArray = {1,33,4,5,7,3,9};
            //int[] outputArray = rotation.LeftRotate(inputArray,2,inputArray.Length);
            //rotation.Print(outputArray);

            Console.WriteLine();
            Console.WriteLine("Waiting for press key");
            Console.ReadKey();
        }
Example #3
0
        static void Main(string[] args)
        {
            #region LinkedList

            /*Console.WriteLine("Add First:");
             * LinkedList myList1 = new LinkedList();
             *
             * myList1.AddFirst("Hello");
             * myList1.AddFirst("Magical");
             * myList1.AddFirst("World");
             * myList1.printAllNodes();
             *
             * Console.WriteLine();
             *
             * Console.WriteLine("Add Last:");
             * LinkedList myList2 = new LinkedList();
             *
             * myList2.AddLast("Hello");
             * myList2.AddLast("Magical");
             * myList2.AddLast("World");
             * myList2.printAllNodes();
             *
             * Console.ReadLine();*/
            #endregion

            #region ReverseString
            //ReverseString reverse = new ReverseString();
            //Console.WriteLine(reverse.ReverseaString("Peru").ToString());
            //Console.ReadLine();
            #endregion

            #region Delegates

            /*Addnumber num = new Addnumber(AddNumbers);
             * Console.WriteLine(num(12, 10));
             * Console.ReadLine();*/

            #endregion

            #region BinaryTree

            /* BinaryTreeImp btObj = new BinaryTreeImp();
             * BinaryNode iniRoot = btObj.addNode(5);
             *
             *
             * btObj.insertNode(btObj.root, iniRoot);
             * btObj.insertNode(btObj.root, btObj.addNode(6));
             * btObj.insertNode(btObj.root, btObj.addNode(10));
             * btObj.insertNode(btObj.root, btObj.addNode(2));
             * btObj.insertNode(btObj.root, btObj.addNode(3));
             * btObj.displayTree(btObj.root);
             * btObj.FindMax(btObj.root);
             * System.Console.WriteLine("The sum of nodes are " + BinaryTreeImp.count);
             * Console.ReadLine();*/


            #endregion

            #region  Split string

            /* string s = "Am12 i12 good";
             * char[] cc = new char[] { '1', '2' };
             * string[] ss = s.Split(cc);
             *
             * SplitString split = new SplitString();
             *
             * SplitString.split(s,new char[] { '1', '2' });*/

            #endregion

            #region StringToNumber
            // StringToNumber.convertToInt("23232");
            //StringToNumber.convertToFloat("232.32");

            // StringToNumber.ConvertToUpperCase("PeRu");
            #endregion

            #region stringOperations
            // StringOperation.ReverseWord();

            // StringOperation.ReverseWordWithoutReversingIndividual();

            #endregion

            #region Sorting Algoritham
            // QuickSortAlgoritham.QuickSort();
            // SelectionSort.selectionSort();
            MergeSort.ImplementMergerSort();
            #endregion

            #region IndexOf finding substring in string
            // IndexOf.IndexOfString();
            #endregion
        }