Question

You are given an input array of integers: [8, 3, 7, 1, 2, 10, 5]. (a)...

You are given an input array of integers: [8, 3, 7, 1, 2, 10, 5].

(a) Build a min-heap for the input data. Draw a figure just to show the min-heap.

(b) Using the min-heap built above, sort the input data in non-descending order using the heap sort algorithm.

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
You are given an input array of integers: [8, 3, 7, 1, 2, 10, 5]. (a)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need the answer selection 3. Given the array of 10 integers shown below, apply bubble...

    I need the answer selection 3. Given the array of 10 integers shown below, apply bubble sort to sort the array of values into descending order (i.e., from large to small). Show the content of the array after the 1" and 2 passes of bubble sort performed on the array. The bubble sort algorithm is given on the last page of the exam if you need a reference. selech 45 34 126 24 18 9021 19 55 Show the content...

  • In the array A[1..10] that stores the elements [35, 30, 25, 27, 22, 20, 18, 15,...

    In the array A[1..10] that stores the elements [35, 30, 25, 27, 22, 20, 18, 15, 10, 5], Construct a min-heap in the array A. Draw the final heap and show its content in the array A. During the construction of heap, show each step of heap construction. Draw the min-heap after removing the Minimum key from 1) and show its content in the array A From the min-heap in 2), sort the array A in the descending order. Draw...

  • Given the following array of integers (of capacity 20) with 12 items: 0 1 2 3...

    Given the following array of integers (of capacity 20) with 12 items: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 4 10 15 5 7 11 3 9 13 1 6             Index of last element = 11 Does this array represent a min heap? If not, convert it to a min heap (i.e., “heapify” it). Please show all steps.

  • Question 10: Given an array of data: array1 10 5 15 2 7 21 Write the...

    Question 10: Given an array of data: array1 10 5 15 2 7 21 Write the code for the selection sort to sort the data and draw a table showing how the data is sorted using selection sort. Write the code for Binary search algorithm to find the value 15 from the sorted array. Draw the tree diagram showing the binary search of the list.

  • 5. A three-heap with n elements can be stored in an array A, where A[O] contains...

    5. A three-heap with n elements can be stored in an array A, where A[O] contains the root of the tree. a) Draw the three-heap that results from inserting 5, 2, 8, 3, 6, 4, 9, 7, 1 in that order into an initially empty three-heap. You do not need to show the array representation of the heap. You are only required to show the final tree, although if you draw intermediate trees. b) Assuming that elements are placed in...

  • 4. (7 pts) Let A be an array of 5 integers, whose contents are as follows:...

    4. (7 pts) Let A be an array of 5 integers, whose contents are as follows: 3, 2, 1, 5, 4. We will apply insertion sort to sort this array. Show all of the element-wise comparisons made by the algorithm in the correct order. Here an element-wise comparison means the comparison of one element of the array with another element of the array or the key set in a particular step of the algorithm. Since the algorithm may move the...

  • Given the array A = (5, 7, 14, 8, 11, 15, 9, 13, 12, 10), show...

    Given the array A = (5, 7, 14, 8, 11, 15, 9, 13, 12, 10), show how the Insertion sort and Quicksort algorithms work. Step through each algorithm, illustrating how it modifies the input array A. State the worst- and best-case computational complexity of the two algorithms in terms of the size |A| of the input array, and explain why.

  • You are given an array containing integers in the sorted order: [O] [1] [2] [3] [4]...

    You are given an array containing integers in the sorted order: [O] [1] [2] [3] [4] [5] [6] [7] 6 9 17 29 33 41 58 61 [8] [9] [10] [11] [12] [13] 67 87 93 112 118 145 We want to find 12 in the given array, using binary search algorithm. The first comparison will be made with ----- 6 58 61 None. 12 is not in the array.

  • Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8...

    Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...

  • 8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array into...

    8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array into a descending order. 42 45 10 64 55 37 96 7 9. (5 points) Trace shell sort algorithm that halves the gap size at each iteration as it sorts the following sequence of integer array into an ascending order. 42 18 10 64 85 37 96 71 8. (5 points) Trace merge sort algorithm as it sorts the following sequence of integer array...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT