RAQ9: Given the following heap, assuming heap entries start at index 1, 68 15/ \40 10/ \8 32/ what will be the content of the corresponding array representation of the heap? 68,15,10,8,40,35 8,10,15,35,40,68 68,15,40,10,8,35 68,40,35,15,10,8
Added by Tiffany W.
Close
Step 1
The root is 68. The left child of 68 is 15, and the right child is 40. The left child of 15 is 10, and the right child is 8. The left child of 40 is 32, and the right child is 35. Show more…
Show all steps
Your feedback will help us improve your experience
Christian Otero and 54 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 a binary-max heap, the elements are stored in an array as 25, 14, 16, 13, 10, 8, 12. What is the content of the array after two delete operations?
Christian O.
Q4. Graph below represent position of the Nodes. Make each Binary search tree, Min heap tree, AVL tree and answer the questions Binary search tree operations Min heap tree operations (Heapify after every insert) Insert 25 Insert 35 Insert 22 Insert 12 Insert 1 Insert 13 Insert 29 Insert 9 Insert 20 Insert 24 Insert 32 Insert 23 Insert 27 Insert 23 Insert 15 Insert 17 Insert 32 Insert 10 Insert 12 Insert 5 Insert 6 Insert 30 Insert 9 Insert 1 26. [BINARY_TREE] What is the value of Node 1 after all operations (Write NULL if there's no value) 31. [MIN_HEAP] What is the value of Node 1 after all operations (Write NULL if there's no value) 27. [BINARY_TREE] What is the value of Node 5 after all operations (Write NULL if there's no value) 32.[MIN_HEAP] What is the value of Node 2 after all operations (Write NULL if there's no value) 28. [BINARY_TREE] What is the value of Node 7 after all operations (Write NULL if there's no value) 33. [MIN_HEAP] What is the value of Node 6 after all operations (Write NULL if there's no value) 29. [BINARY_TREE] What is the value of Node 17 after all operations (Write NULL if there's no value) 34. [MIN_HEAP] What is the value of Node 11 after all operations (Write NULL if there's no value) 30. [BINARY_TREE] What is the value of Node 18 after all operations (Write NULL if there's no value) 35.[MIN_HEAP] What is the value of Node 12 after all operations (Write NULL if there's no value)
Akash M.
Draw the array along with the tree diagram tracing the steps to sort the following list of numbers using heapsort. 33 20 4 0 36 5 I strongly recommend using a spreadsheet. If you're more comfortable with some other software, that's fine, but I think drawing this out by hand will be nearly impossible. To do this correctly you must view the lecture video demonstration. You must draw the array and tree diagram every time a swap is performed! I realize that this may be a bit tedious, but it's important. Here is an algorithm you can follow. I'm hoping this will help, but if it's easier to just follow along with the example in the lecture, that's fine too. Note that Every time you do a swap or highlight an item, you must do it in both the array and the corresponding tree diagram. Draw the original diagram; while (array does not represent a heap) { Copy/paste the diagram; Perform the next required swap; } while (some nodes other than the root remain un-highlighted) { Copy/paste the diagram; if (the array represents a heap) { Swap array[0] with the last unhighlighted item in the array; highlight that item. } else { Perform the next required swap; } } My solution has 13 swaps (thus, 14 copies of the diagram).
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD