Question

Given the following list of keys 49, 53, 25, 40, 3, 60, 2, 48, 1, 49,...

Given the following list of keys 49, 53, 25, 40, 3, 60, 2, 48, 1, 49, 40.

Show the result of using the linear-time algorithm to build a binary heap (BuildHeap) using the same list of keys. Are these the same, if not explain why.

Homework Answers

Answer #1

Explinatation:-

1) in the question they didn’t mention about the max heap are min heap let us consider min heap.

2) that means at any node the value of that node is smaller than its children except leaf nodes since leaf node doesn’t have children.

3)now initially we inserted 49 by default one element is min heap

4)next insert 53 left to 49 so it is satisfying min heap property

5)next insert 25 right to 53 after this it is failing the min heap property so now we needo swap 49 and 25 now it will satisfy the min heap property.

6)next insert 40 next 3 now after inserting 3 it is failing the min heap property and swap with above its parent again go to till root node until it should not fail min heap property.

7)so like that continue for remaining elements.

Know the answer?
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
Similar Questions
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at...
(a) Consider an initially empty max-heap, where the following keys are to be inserted one at a time: 11, 19, 23, 12, 13, 17, 13, 14, 18, and 33. Draw the tree that results after building this max-heap. (b) Show the result of inserting 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2, one at a time and in the giver order , into an initially empty binary min heap. (c) Show the...
Given the following keys: Keys: 500, 300, 450, 650, 700, 400, 660, 550, 680, 430, 590...
Given the following keys: Keys: 500, 300, 450, 650, 700, 400, 660, 550, 680, 430, 590 A) Create a binary search tree. B) Represent the binary search tree in part A in an array. C) Show your tree in Part A after deleting the root. D) Define a binary tree (without duplication, with more than 3 nodes) such that the result of the Inorder and Postorder traversal are the same).
Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. Build a...
Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. Build a MAX-HEAP on A. Show the steps using binary tree representation or array view. Use heap sort: show the array after the first, the second, and the third of heap sort
Output(units) Total Revenue($) Total Cost($) 0 0 25 1 30 49 2 60 69 3 90...
Output(units) Total Revenue($) Total Cost($) 0 0 25 1 30 49 2 60 69 3 90 86 4 120 100 5 150 114 6 180 128 7 210 170 Using the table above,  May you please show the calculations step by step. Thank you:) Which gives the total revenue schedule and total cost schedule of a perfectly competitive firm. The short-run equilibrium price of one unit of the good is: A) $3. B) $10. C) $15. D) $25. E) $30. May...
for the following array 30 5 40 11 20 9 15 2 60 25 80 3...
for the following array 30 5 40 11 20 9 15 2 60 25 80 3 73 35 4 75 20 6 Show the new array after each pass of Merge sort. Show the new array after each pass of Quick sort.
square the elements of a linear list of numbers (square ‘(1 -3 -5 7)) => (1...
square the elements of a linear list of numbers (square ‘(1 -3 -5 7)) => (1 9 25 49) using DrRacket The code has to be from scratch, no library functions. and kindly explain what each line of code is doing.
Age Frequency Midpoint f*M f*(M-xbar)2 30-39 2 40-49 3 50-59 7 60-69 5 70-79 1 Compute...
Age Frequency Midpoint f*M f*(M-xbar)2 30-39 2 40-49 3 50-59 7 60-69 5 70-79 1 Compute the Coefficient of Variation to 2 decimal places. Do NOT format answer: No $, Commas, %.
1. Given the data set: 40, 40, 35, 48, 38, 40, 36, 50, 32, 36, 40,...
1. Given the data set: 40, 40, 35, 48, 38, 40, 36, 50, 32, 36, 40, 35, 30, 24, 40, 36, 40, 39, 33, 40, 32, 38, construct an appropriate frequency distribution table and draw a frequency histogram, frequency polygon, and ogive. number of classes =5 2. Use the following table to find the following probabilities: Nursing Majors Non-Nursing Majors Total Males 94 1104 1198 Females 725 1682 2407 Total 819 2786 3605 a. The student is male or a...
Period Price Quantity 1 $4.65 33 2 $4.67 30 3 $4.62 35 4 $4.59 40 5...
Period Price Quantity 1 $4.65 33 2 $4.67 30 3 $4.62 35 4 $4.59 40 5 $4.57 43 6 $4.58 40 7 $4.55 50 8 $4.50 52 9 $4.52 49 10 $4.50 53 11 $4.43 57 12 $4.45 55 13 $4.42 59 14 $4.40 64 15 $4.44 60 16 $4.37 70 17 $4.35 72 18 $4.32 75 19 $4.37 80 20 $4.26 88 Given the data provided to you in class, use the regression toll in Excel to perform a...
Create a program using Binary Trees in Java to do the following 1. Verify a given...
Create a program using Binary Trees in Java to do the following 1. Verify a given expression is balanced in regards to parentheses 2. covert an infix expression to a postfix expression 3. Evaluate the expression Given expressions: String s[] = {"5 + ) * ( 2", " 2 + ( - 3 * 5 ) ", "(( 2 + 3 ) * 5 ) * 8 ", "5 * 10 + ( 15 - 20 ) ) - 25",...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT