Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Homework 4 - Heaps Write a program (using the textbook code provided in my git repository) to take N elements, of whatever kinds of objects you’d like) and do the following: a

Computer Science Aug 06, 2021

Homework 4 - Heaps

Write a program (using the textbook code provided in my git repository) to take N elements, of whatever kinds of objects you’d like) and do the following:

a. Insert them into a heap one by one.

b. Build a heap in linear time using buildHeap

(You’ll get bonus points if you use something more interesting than Integers for this)

Compare and provide an analysis of the running time of both algorithms for sorted, reverse-ordered, and randomly-ordered inputs. You’ll obviously have to run this a bunch of times with different values of N. Try ranges between one thousand and ten million. How does the timing depend on N, and the ordering of the data at the start? Plot the data in Excel or a similar program to do your analysis. Upload this analysis as a PDF into your git repository, just as you would with a source-code file. Below is an example of how to do timing of an algorithm in a java program:

import java.util.concurrent.TimeUnit;

class TimeExample

{

public static void main(String[] args) throws InterruptedException { long start = System.nanoTime(); // ... the code being timed goes here ... // as an example: sleep for 5 seconds TimeUnit.SECONDS.sleep(5); // ... the code being timed ends ... long end = System.nanoTime(); long msElapsed = (end - start) / 1000000; System.out.println("Execution time in milliseconds: " + msElapsed); } }

Expert Solution

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment