Question

In: Computer Science

Related to HeapSort (a) Construct a heap for the following array of numbers:         8 1 2...

Related to HeapSort

(a) Construct a heap for the following array of numbers:         8 1 2 3 5 6 4 7 10 9

      Show the array after the insertion of each element into the heap.

(b) Use your heap to sort the array. Show the resulting heap after the extraction of each maximum.

Solutions

Expert Solution

Hope this resolves your doubt.

Please give an upvote if you liked my solution. Thank you :)


Related Solutions

1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array...
1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array to a temp array 3.) Call each of the methods to sort (bubble, selection, insertion, quick, merge), passing it the array 4.) In-between the calls, you are going to refresh the array to the original numbers. 5.) Inside of each sorting method, you are going to obtain the nanoseconds time, before and after the method Subtract the before time from the after time to...
We consider Heapsort to sort an array in decreasing order by using min-heaps. 1. State the...
We consider Heapsort to sort an array in decreasing order by using min-heaps. 1. State the min-heap property. Then, using the same notation as in the textbook, write pseudocode for the following functions (where A is the min-heap) Then, using the same notation as in the textbook, write pseudocode for the following functions (where A is the min-heap): 2. Min-Heapify(A, i), which assumes that the binary trees rooted at Left(i) and Right(i) are min-heaps, but that A[i] may be larger...
Create the following algorithms in c++ as a call to method: 1. HeapSort 2. QuickSort 3....
Create the following algorithms in c++ as a call to method: 1. HeapSort 2. QuickSort 3. MergeSort
Write a program in C that declares the following array: int. array[] = { 1, 2,...
Write a program in C that declares the following array: int. array[] = { 1, 2, 4, 8, 16, 32 } Then write some code that accepts a number between 0 and 5 from the user and stores it in a variable called "index". Write some code that retrieves the item specified by the index, like this: int item = array[index]; Then write code that outputs the corresponding array entry based on the number the user entered. Example output: The...
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]
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8,.... Formally,...
The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8,.... Formally, it can be expressed as: fib0 = 0 fib1 = 1 fibn = fibn-1 + fibn-2 Write a multithreaded C++ program that generates the Fibonacci series using the pthread library. This program should work as follows: The user will enter on the command line the number of Fibonacci numbers that the program will generate. The program will then create a separate thread that will...
Suppose we have an array A that contains a prime numbers from 2 to 200 in...
Suppose we have an array A that contains a prime numbers from 2 to 200 in sorted order. How many items of the array A would the binary search algorithm have to examine before concluding that 60 is not in the array A? 30 200 100 6 2- Suppose we have an array that contains 182 village name. These names are sorted alphabetically. How many names would binary search algorithm examine to locate a particular name in the array, in...
Suppose that the array X consists of real numbers X[1], X[2], …, X[N]. Write a pseudocode...
Suppose that the array X consists of real numbers X[1], X[2], …, X[N]. Write a pseudocode program to compute the minimum of these numbers.
Build a Max Heap using the following: A= {20, 15, 10, 14, 8, 6, 9}
Build a Max Heap using the following: A= {20, 15, 10, 14, 8, 6, 9}
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT