Show the result of using the linear-time algorithm to build a binary heap for th
ID: 3544847 • Letter: S
Question
Show the result of using the linear-time algorithm to build a binary heap for this order 10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, and 2.
Explanation / Answer
10 10 10 1 1 / / --> / / 12 12 1 12 10 12 10 / 14 1 1 1 1 / / / / 12 10 --> 6 10 6 10 --> 6 5 / / / / / / 14 6 14 12 14 12 5 14 12 10 1 1 1 1 / / / / 6 5 6 5 6 5 --> 3 5 / / / / / / / / 14 12 10 8 14 12 10 8 14 12 10 8 6 12 10 8 / / / 15 15 3 15 14 And so on. Final heap: 1 / 3 2 / / 6 7 5 4 / / / / 15 14 12 9 10 11 13 8 The array looks like (if started at one): +---+---+---+---+---+---+---+----+----+----+---+----+----+----+---+ Contents: | 1 | 3 | 2 | 6 | 7 | 5 | 4 | 15 | 14 | 12 | 9 | 10 | 11 | 13 | 8 | +---+---+---+---+---+---+---+----+----+----+---+----+----+----+---+ Subscript: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.