Question NO.1 : Illustrate the operation of heapSort on the array shown below to get the following result A = \{35, 45, 61,82, 85, 101\}. A= \{45, 101, 82, 61, 35, 85\}
Added by Shawna S.
Close
Step 1
- Start with the last non-leaf node, which is at index (n/2)-1 = (6/2)-1 = 2. - Compare the parent node with its children and swap if necessary to maintain the max heap property. - After the first iteration, the max heap will be: A = {35, 45, 101, 82, 85, 61} Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 93 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Given the following max heap, assuming heap entries start at index 1, show the heap after adding the entry 87 using the array representation: 4 5 6 1 2 3 0 8 7 24 12 40 45.
Akash M.
In Problems 35-40, find a recursive definition for the sequence. 35. 1, 3, 5, 7, 9, ... 36. 2, 4, 6, 8, 10, ... 37. 3, 5, 9, 17, 33, ... 38. 1, 5, 14, 30, 55, ... 39. 1, 3, 6, 10, 15, ... 40. 1, 2, 3/2, 5/3, 8/5, 13/8, ...
Chloe F.
Using Quick Sort Algorithm, illustrate how to perform the first partitioning operation to sort the following array in a non-decreasing order. A = {10, 15, -8, 7, 0, 5, 6, 1, 20, 12, 11, 14}.
Sri K.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD