Question

In: Computer Science

Part A Write a 6-8 sentence summary explaining how you can use the Heap Sort algorithms...

Part A

Write a 6-8 sentence summary explaining how you can use the Heap Sort algorithms to solve a real world problem. In your summary, provide a descriptive or visual explanation of your heapsort solution.

Part B

For this portion of the assignment you will design an algorithm to implement the solution described in part A. Your algorithm must be written in pseudocode.

Note:

Sample HeapSort Algorithm Pseudocode:

Heapsort(A as array)
    BuildHeap(A)
    for i = n to 1
        swap(A[1], A[i])
        n = n - 1
        Heapify(A, 1)

BuildHeap(A as array)
    n = elements_in(A)
    for i = floor(n/2) to 1
        Heapify(A,i,n)

Heapify(A as array, i as int, n as int)
    left = 2i
    right = 2i+1

    if (left <= n) and (A[left] > A[i])
        max = left
    else 
        max = i

    if (right<=n) and (A[right] > A[max])
        max = right

    if (max != i)
        swap(A[i], A[max])
        Heapify(A, max)

Solutions

Expert Solution

Answer:

A heap sort can be implemented as a priority queue.

It can be used to quickly find the smallest and largest element from a collection of items or array.

It can be used in the implementation of the Priority queue in graph algorithms like Dijkstra's algorithm (shortest path), Prim's algorithm (minimum spanning tree) and Huffman encoding (data compression).

In order to overcome the Worst-Case Complexity of Quick Sort algorithm from O(n^2) to O( nlog(n) ) in Heap Sort.

For finding the order in statistics.

Systems concerned with security and embedded system such as Linux Kernel uses Heap Sort because of the O( nlog(n) ).

Instead of just joining a queue at its tail, a person or object may be inserted further up the queue depending on their priority.

Algorithm for heap sort:

Start
Heap sort():
{
 for each value from n/(2-1) to 0:
 {
    heapify (array, n and i)
    for each value from n-1 to 0:
    {
       swap the values in an array;
       Then again heapify (arr, i, 0);
    }
}
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Explain how you can utilize a minimum heap to sort the list of number in descending...
Explain how you can utilize a minimum heap to sort the list of number in descending order. Let n-be the number of elements in the list. What is the complexity of your sorting algorithm.Explain how you can utilize a minimum heap to sort the list of number in descending order. Let n-be the number of elements in the list. What is the complexity of your sorting algorithm.Please explain through example and give algorithem in written form (no code).
2) Write an essay explaining the particulars related to hypothesis testing and how you can use...
2) Write an essay explaining the particulars related to hypothesis testing and how you can use such an approach to explore a hypothesis or theory that you might be interested in pursuing.
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from...
Design and analysis of Algorithms: How do I write a k way merge sort algorithm from a merge sort algorithm that splits 2 arrays while sorting?
Write a program that implements the follow disk scheduling algorithms. You can use C or Java...
Write a program that implements the follow disk scheduling algorithms. You can use C or Java for this assignment. FCFS SSTF SCAN C-SCAN LOOK C-LOOK Your program will service a disk with 5000 cylinders (numbered 0 to 4999). Your program will generate a random initial disk head position, as well as a random series of 1000 cylinder requests, and service them using each of the 6 algorithms listed above. Your program will report the total amount of head movement required...
Write a program to sort the following using HeapSort. Use any language you want. A=[10, 8,...
Write a program to sort the following using HeapSort. Use any language you want. A=[10, 8, 7, 9,16, 14, 3, 2, 4, 1]
Please let me know how to make code sort. If you put sort (sort 1000 6...
Please let me know how to make code sort. If you put sort (sort 1000 6 5 4 3 2 1, not separate), you will get 1 2 3 4 5 6 1000. sort 50 300 27 5 5 27 50 300 public static void main (String[] args) {        Scanner scnr = new Scanner(System.in);        String a = "";            a = scnr.nextLine();            String[] b = imput.split(" ") if (b[0].equalsI("sort")) { }...
What is capital structure and how important it is? write 8 sentences explaining it with detail...
What is capital structure and how important it is? write 8 sentences explaining it with detail thanks.
USE JAVA. Write a very general sort method that can sort any type of data arrays/lists....
USE JAVA. Write a very general sort method that can sort any type of data arrays/lists. For example, can sort a list of integers in ascending order, a list of integers in descending order, a list of doubles, a list of student objects (with names and scores) in ascending order of names, or in descending order of scores, … You can use any pre-defined sort function or can code your own. Use your favorite language for implementation. If your language...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT