Please answer point 3 and 4 In Data Structures, you studied binary heaps. Binary heaps support the insert and extractMin functions in O(lgn), and getMin in O(1). Moreover, you can build a heap of n...




Please answer point 3 and 4


In Data Structures, you studied binary heaps. Binary heaps support the insert and extractMin
functions in O(lgn), and getMin in O(1). Moreover, you can build a heap of n elements in
just O(n). Refresh your knowledge of heaps from chapter no. 6 of your algorithms text book.
Now implement Merge Sort, Heap Sort, and Quick Sort in C++ and perform the following
experiment:
1. Generate an Array A of 10^7 random numbers. Make its copies B and C. Sort A using
Merge Sort, B using Heap Sort, and C using Quick Sort.
2. During the sorting process, count the total number of comparisons between array ele-
ments made by each algorithm. You may do this by using a global less-than-or-equal-to
function to compare numbers, which increments a count variable each time it is called.
3. Repeat this process 5 times to compute the average number of comparisons made by
each algorithm.
4. Present these average counts in a table. These counts give you an indication of how the
di erent algorithms compare asymptotically (in big-O terms) for a large value of n.



a. In Data Structures, you studied binary heaps. Binary heaps support the insert and extractMin<br>functions in O(lgn), and getMin in 0(1). Moreover, you can build a heap of n elements in<br>just O(n). Refresh your knowledge of heaps from chapter no. 6 of your algorithms text book.<br>Now implement Merge Sort, Heap Sort, and Quick Sort in C++ and perform the following<br>experiment:<br>1. Generate an Array A of 107 random numbers. Make its copies B and C. Sort A using<br>Merge Sort, B using Heap Sort, and C using Quick Sort.<br>2. During the sorting process, count the total number of comparisons between array ele-<br>ments made by each algorithm. You may do this by using a global less-than-or-equal-to<br>function to compare numbers, which increments a count variable each time it is called.<br>3. Repeat this process 5 times to compute the average number of comparisons made by<br>each algorithm.<br>4. Present these average counts in a table. These counts give you an indication of how the<br>different algorithms compare asymptotically (in big-0 terms) for a large value of n.<br>

Extracted text: a. In Data Structures, you studied binary heaps. Binary heaps support the insert and extractMin functions in O(lgn), and getMin in 0(1). Moreover, you can build a heap of n elements in just O(n). Refresh your knowledge of heaps from chapter no. 6 of your algorithms text book. Now implement Merge Sort, Heap Sort, and Quick Sort in C++ and perform the following experiment: 1. Generate an Array A of 107 random numbers. Make its copies B and C. Sort A using Merge Sort, B using Heap Sort, and C using Quick Sort. 2. During the sorting process, count the total number of comparisons between array ele- ments made by each algorithm. You may do this by using a global less-than-or-equal-to function to compare numbers, which increments a count variable each time it is called. 3. Repeat this process 5 times to compute the average number of comparisons made by each algorithm. 4. Present these average counts in a table. These counts give you an indication of how the different algorithms compare asymptotically (in big-0 terms) for a large value of n.
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here