Question: Please write in java if you can. Also can you show me the results you get when you run the code. Consider the following set

Please write in java if you can. Also can you show me the results you get when you run the code.

Consider the following set of elements: 23, 53, 64, 5, 87, 32, 50, 90, 14, 41

  1. Construct a min-heap binary tree to include these elements.
  2. Implement the above min-heap structure using an array representation as described in class.
  3. Visit the different array elements in part b and print the index and value of the parent and children of each element visited. Use the formulas for finding the index of the children and parent as presented in class.
  4. Implement the code for inserting the values 44, and then 20 into the min-heap.
  5. Select a random integer in the range [0, array_size-1]. Delete the heap element at that heap index and apply the necessary steps to maintain the min-heap property.
  6. Increase the value of the root element to 25. Apply the necessary steps in code to maintain the min-heap property.
  7. Change the value of the element with value 50 to 0. Apply the necessary steps in code to maintain the min-heap property.
  8. Implement the delete-min algorithm on the heap.
  9. Recursively apply the delete-min algorithm to sort the elements of the heap.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!