In Java, please.
Binary Heap
Write a Java program to build a Binary heap for 100 random numbers between
0 and 500. These numbers need to be generated by a random function.
Your program should have two types of AddElement methods, one creates a
Binary heap by inserting the input elements one at a time, into an initially
empty binary. The other method creates a Binary heap by using the linear-
time algorithm to build a heap using the same input.
Input 20 positive integers generated by a random function ranged between 0 and 500 and put them into one-dimensional array.
Output: Calculate the total number of swappings - Print out the elements in the result of each binary heap with
iteratorPreOrderMethod (Remember, a heap extends a
binary tree).
- Print out the execution time for each add method.