Question: Problem 1: (Use Java) In this problem, you are going to implement heap sort for sorting data items both in ascending and descending order. For

Problem 1: (Use Java)

In this problem, you are going to implement heap sort for sorting data items both in ascending and descending order. For this, you have to do following things:

=> You have to build a heap first from the given array. Write a method called BuildMaxHeap (). We know Building heap requires iterative execution of insertion operations. Write a method called InsertToMaxHeap () to insert a new item into an existing maxheap. Create a method called DeleteFromMaxHeap () to delete root successively and reheap the existing nodes. Now write a method called HeapSortAscending (A, N), where A is the given array, and N is the no of data items. Combine all the methods so that it performs sorting in ascending order.

=> Do the same thing for sorting in descending order. However, this time, youve to create the following methods:

--BuildMinHeap (), InsertToMinHeap (), DeleteFromMinHeap (), HeapSortDescending (A, N)

NB: For your convenience, you may assume that all the data items will be integer.

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!