Question

In: Computer Science

Make a program to perform Heap Sort, must run in Alice programming only. Only correct answers...

Make a program to perform Heap Sort, must run in Alice programming only. Only correct answers needed should be in given language Wrong answers will be downvoted

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Heap sort algorithm is divided into two basic parts:

  • Creating a Heap of the unsorted list/array.
  • Then a sorted array is created by repeatedly removing the largest/smallest element from the heap, and inserting it into the array. The heap is reconstructed after each removal.

Initially on receiving an unsorted list, the first step in heap sort is to create a Heap data structure(Max-Heap or Min-Heap). Once heap is built, the first element of the Heap is either largest or smallest(depending upon Max-Heap or Min-Heap), so we put the first element of the heap in our array. Then we again make heap using the remaining elements, to again pick the first element of the heap and put it into the array. We keep on doing the same repeatedly untill we have the complete sorted list in our array.

Kindly revert for any queries

Thanks.


Related Solutions

LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that...
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that sorts the array below in ascending order.  LISP is a recursive language so the program will use recursion to sort. Since there will be no loops, you will not need the variables i, j, and temp, but still use the variable name array for the array to be sorted.             Array to be sorted is 34, 56, 4, 10, 77, 51, 93, 30, 5, 52 The...
Write a C++ program that attempts to make the Radix Sort more practical: make it sort...
Write a C++ program that attempts to make the Radix Sort more practical: make it sort strings of a maximum length of 15. Have an array of strings. Then in the Radix Sort, create an array of LinkedQueue with 95 queues (95 are the printable characters starting with space). Those queues will be used to separate the data then combine them (i.e. bins). Randomly generate 10,000 strings with lengths from 1 to 15 (during the sort and with strings less...
Write a C++ program that attempts to make the Radix Sort more practical: make it sort...
Write a C++ program that attempts to make the Radix Sort more practical: make it sort strings of a maximum length of 15. Have an array of strings. Then in the Radix Sort, create an array of LinkedQueue with 95 queues (95 are the printable characters starting with space). Those queues will be used to separate the data then combine them (i.e. bins). Randomly generate 10,000 strings with lengths from 1 to 15 (during the sort and with strings less...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and...
C++ Heap Tree:  Make a program called "priority_queue" that has the following operations using a heap and simulating a prioritized row of integers with higher priority value. I would appreciate if someone could help me with this code It has to include the following on the code: push Description: Add data to prioritized row Entry: An integer, which you want to add to the prioritized row Exit: Nothing Precondition: n is an integer Postcondition: The prioritized row contains new data. pop...
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude...
Write a program that performs a merge-sort algorithm without using a recursion. c++ programming language(Only #inlclude <iostream>)
Complete the coding/testing of the heap sort method we began in class. Then modify your program...
Complete the coding/testing of the heap sort method we began in class. Then modify your program so that it outputs a comparison of the actual number of swaps it performs to the predicted number of swaps, and a comparison of the actual sort effort to the predicted and minimum sort effort. The output should be formatted exactly as shown below. Actual swaps = xxxx; Predicted swaps = xxxx Actual sort effort = xxxx; Predicted sort effort = xxxx; Min sort...
Design a program which uses functions to sort a list and perform a binary search. Your...
Design a program which uses functions to sort a list and perform a binary search. Your program should: Iinitialize an unsorted list (using the list provided) Display the unsorted list Sort the list Display the sorted list. Set up a loop to ask the user for a name, perform a binary search, and then report if the name is in the list. Use a sentinel value to end the loop. Do not use the Python built in sort function to...
Programming assignment for ENSC 3213 NIM The program is to be written in Matlab. Program must...
Programming assignment for ENSC 3213 NIM The program is to be written in Matlab. Program must be liberally commented. The program is a game played by a human versus the machine. At the start, the prompt asks the human to enter three non-zero integers. These will constitute how many counters are in each Pile. The machine then asks who goes first. A turn consists of selecting a Pile and taking a number of counters from that pile. For example, if...
Using C# programming language, Write a program that sort three numbers entered by the user using...
Using C# programming language, Write a program that sort three numbers entered by the user using only if and nested if statements. If for instance the user entered 5, 2, and 7; the program should display 2,5,7.
This programming assignment will consist of a C++ program. Your program must compile correctly and produce...
This programming assignment will consist of a C++ program. Your program must compile correctly and produce the specified output. Please note that your programs should comply with the commenting and formatting described in the Required Program Development Best Practices document that has been discussed in class and is posted to the eLearning system. Please see this descriptive file on the eLearning system for more details. The name to use in the main configuration screen text box Name: [ ] in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT