Exercise 2: Build Heap Time
- Due Mar 20, 2024 by 11:59pm
- Points 11
- Submitting a file upload
- Available Mar 10, 2024 at 1pm - Mar 21, 2024 at 11:59pm
Your textbook proves that the Build-Max-Heap algorithm is O(n). You will perform an empirical experiment to support that its running time does increase linearly with the size (n) of the array placed in max-heap order.
Start with the following program: CSI318-Exercise 2 (Build Max Heap).zip Download CSI318-Exercise 2 (Build Max Heap).zip, which contains C++ code to time runs of a buildMaxHeap() function on randomized arrays of increasing size.
To complete the empirical experiment, do the following:
- Implement the Build-Max-Heap algorithm from the book in the empty function buildMaxHeap(). You should also write other functions, such as one to recursively implement the Max-Heapify procedure. Note: The array is made large enough so that you can ignore element [0] and use 1-based indices like the book. Document your implementation with comments. Include your name at the top of the program.
- Run the program, which uses functionality from the <chrono> library to time multiple runs at each array size.
- Collect the output from the program as a text file.
- Use Excel (or Google Sheets) to plot the array sizes (n) vs. accumulated times across multiple runs (microseconds). Add a descriptive title to the top of the chart, label the x and y axes, and add a trendline. Your plot should (hopefully) show a linear trend! Export the plot as an image.
Zip up the folder containing the completed Visual Studio solution (remember to remove some files per the instruction video). Upload the zipped folder, a separate text file (program output), and image (plot) here for this assignment.
Rubric
Please include a title
Keep in mind that 3 students have already been assessed using this rubric. Changing it will affect their evaluations.
Criteria | Ratings | Pts | |
---|---|---|---|
Code: Calculations to compute child indices.
threshold:
pts
|
pts
--
|
||
Code: Max-Heapify algorithm function implementation.
threshold:
pts
|
pts
--
|
||
Code: Build-Max-Heap algorithm function implementation.
threshold:
pts
|
pts
--
|
||
Code: Correctly used 1-based indices.
threshold:
pts
|
pts
--
|
||
Documentation of algorithms in code.
threshold:
pts
|
pts
--
|
||
Collected time data (text file) and graph with title, axes labels, trends line.
threshold:
pts
|
pts
--
|
||
Total Points:
11
out of 11
|