Esempio n. 1
0
        static void Main(string[] args)
        {
            int[]    nums = { 10, 64, 7, 52, 32, 18, 2, 48 };
            HeapSort hs   = new HeapSort();

            hs.PerformHeapSort(nums);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            int[] arr = new int[] { 11, 2, 44, 56, 789, 34, 3, 15, 28, 40, 42, 605 };

            HeapSort.Sort(arr);

            Console.WriteLine(string.Join(' ', arr));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            int[]    arr = { 10, 64, 7, 52, 32, 18, 2, 48 };
            HeapSort hs  = new HeapSort();

            hs.PerformHeapSort(arr);
            Console.ReadLine();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            int[]    v    = { 54, 31, 5, 79, 1, 21, 22, 19, 66, 31 };
            HeapSort heap = new HeapSort();

            heap.Sort(v);

            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            int[]    array = { 15, 18, 3, 25, 14, 11, 30, 26, 7 };
            int      n     = array.Length;
            HeapSort a     = new HeapSort();

            a.Sort(array);

            Console.WriteLine("Sorted array is");
            a.Print(array);
        }
Esempio n. 6
0
        public static void Main()
        {
            int[] arr = { 12, 11, 13, 5, 6, 7 };
            int   m   = arr.Length;

            HeapSort ob = new HeapSort();

            ob.sort(arr);

            Console.WriteLine("Sıralanmış dizi");
            printArray(arr);
        }
        public static void Main()
        {
            int[] arr = { 30, 16, 5, 9, 2, 12, 4, 10 };
            Console.WriteLine("Unsorted array:");
            printArray(arr);
            int      n  = arr.Length;
            HeapSort ob = new HeapSort();

            ob.sort(arr);
            Console.WriteLine("\nSorted array:");
            printArray(arr);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            int[]    arr = { 1, 10, 5, 63, 17, 51, 33, 58, 22, 6, 92 };
            HeapSort hs  = new HeapSort();

            hs.PerformHeapSort(arr);
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");
            }
            Console.ReadLine();
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            int[] val = { 3, 2, 4, 1, 5 };

            HeapSort <int> sort = new HeapSort <int>();

            val = sort.Sort(val);

            ;

            Console.ReadKey();
        }
Esempio n. 10
0
            public void Run(List <LinkedList <int> > collection, string filename)
            {
                Stopwatch timer       = new Stopwatch();
                var       TestResults = new StringBuilder();

                foreach (var t in collection)
                {
                    var heapSort = new HeapSort();
                    timer = Stopwatch.StartNew();
                    heapSort.Sort(t);
                    timer.Stop();
                    TestResults.AppendFormat("{0}; {1}; {2}\n", t.Count,
                                             (double)timer.ElapsedMilliseconds,
                                             heapSort.Iterations);
                }

                File.WriteAllText(filename, TestResults.ToString());
            }
Esempio n. 11
0
        public static void Main()

        {
            int[] arr = { 30, 16, 5, 9, 2, 12, 4, 10 };
            Console.WriteLine("Array before sorting:");

            printArray(arr);

            int n = arr.Length;

            HeapSort ob = new HeapSort();

            ob.sort(arr);

            Console.WriteLine("\nArray after sorting:");

            printArray(arr);
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
            Random rand = new Random();

            int[] arr1 = new int[15];
            int[] arr2 = new int[15];

            for (int i = 0; i < 15; i++)
            {
                arr1[i] = rand.Next(0, 15);
                arr2[i] = rand.Next(0, 15);
                Console.Write(arr1[i] + "  ");
            }
            Console.WriteLine("");

            watch.Reset();
            watch.Start();
            HeapSort <int> .sort(arr1);

            watch.Stop();
            Console.WriteLine("HeapSort took: " + watch.Elapsed);

            watch.Reset();
            watch.Start();
            bubbleSort(arr2);
            watch.Stop();
            Console.WriteLine("Bubble sort took: " + watch.Elapsed);

            foreach (int a in arr1)
            {
                Console.Write(a + "  ");
            }
            Console.WriteLine("");

            int[] bigArr1 = new int[500];
            int[] bigArr2 = new int[500];

            for (int i = 0; i < 500; i++)
            {
                bigArr1[i] = rand.Next(0, 500);
                bigArr2[i] = rand.Next(0, 500);
                Console.Write(bigArr1[i] + "  ");
            }
            Console.WriteLine("");
            Console.WriteLine("");

            watch.Reset();
            watch.Start();
            HeapSort <int> .sort(bigArr1);

            watch.Stop();
            Console.WriteLine("HeapSort took: " + watch.Elapsed);

            watch.Reset();
            watch.Start();
            bubbleSort(bigArr2);
            watch.Stop();
            Console.WriteLine("Bubble sort took: " + watch.Elapsed);

            for (int i = 0; i < 500; i++)
            {
                Console.Write(bigArr1[i] + "  ");
            }


            int[] veryBig1 = new int[50000];
            int[] veryBig2 = new int[50000];

            for (int i = 0; i < 50000; i++)
            {
                veryBig1[i] = rand.Next(0, 50000);
                veryBig2[i] = rand.Next(0, 50000);
            }
            Console.WriteLine("");
            Console.WriteLine("");

            watch.Reset();
            watch.Start();
            HeapSort <int> .sort(veryBig1);

            watch.Stop();
            Console.WriteLine("HeapSort took: " + watch.Elapsed);

            watch.Reset();
            watch.Start();
            bubbleSort(veryBig2);
            watch.Stop();
            Console.WriteLine("Bubble sort took: " + watch.Elapsed);
        }