Exemplo n.º 1
0
 private static void TestMergeSort()
 {
     int[] nums = { 4, 5, 3, 8, 9, 1, 23, 2, 6, 75 };
     MergeSorter.DoMergeSort(nums);
     foreach (int number in nums)
     {
         Console.Write(number + " ");
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var array = new int[] { 3, 9, 1, 34, 9, 10, -3 };

            Console.WriteLine("Before sorting");
            array.WriteEachElement();

            //Console.WriteLine("\n\nAfter SelectionSort");
            //MergeSorter.Sort(array);
            //array.WriteEachElement();

            Console.WriteLine("\n\nAfter BottomUp merge sort");
            MergeSorter.Sort(array);
            //array.WriteEachElement();
            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main()
        {
            MergeSorter oSorter = new MergeSorter();
            ArrayList arrayUnsorted= new ArrayList();
            Console.WriteLine("How many numbers will you be sorting?");
            Console.Write("Number count: ");
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                Console.Write("Number[{0}] = ", i + 1);
                arrayUnsorted.Add(int.Parse(Console.ReadLine()));
            }

            ArrayList arraySorted = oSorter.MergeSort(arrayUnsorted);

            foreach (int i in arraySorted)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
        }
 public void SetUp()
 {
     sorter = new MergeSorter();
 }