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

(C++)Heapsort: Write C++ codes for heapsort. The input array is a random permutation of A={1, 2,...
(C++)Heapsort: Write C++ codes for heapsort. The input array is a random permutation of A={1, 2, 3, …, 99, 100}. You should write codes to generate and print the random permutation first.
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
1. Please convert the following decimal numbers to 8-bit binary sign magnitude and to 8-bit 2’s...
1. Please convert the following decimal numbers to 8-bit binary sign magnitude and to 8-bit 2’s complement. Please show your work if there are multiple steps. Sign Magnitude 2’s complement a. +67 b. +40 c. -28 d. -40
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]
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is...
1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is the running time of the insertion sort if both A[1..n/2] and A[n/2+1,n] are also sorted. Justify your answer. 2-illustrate the operation of RADIX-SORT on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, TEA, NOW, FOX. 3-Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3
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 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT