YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Patch Up A Heap - Intro to Algorithms

Get Embed Code
3 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. All right, before we actually write a code that carries out this procedure, let's do an example.
  2. Here's a lovely heap. In fact, well, I just covered this up.
  3. It's a lovely heap where each of the nodes is smaller or no larger than any of its children,
  4. except for this pesky 50 at the root.
  5. Using what I described in the previous slide what we're just talking about,
  6. you can actually patch this up by moving the 50 around doing some various swaps.
  7. In fact, you have do do a series of swaps.
  8. And when the swapping is all done, which node in the tree, according to the red numbering,
  9. which node is going to be the resting place of 50 once the heap property is established?
  10. Just write the node number where 50 ends up in the box.