Heap Sorting Challenge 4: "Heap-pocalypse"!

Sort this binary heap: 0 1 3 2 0 1 2 3 2 3 1 0 0

Click here to see the solution or proceed to Challenge 5!

Binary Heap:

Sort me, mortal!

Heap

Challenge Rules:

1. Start at the root node.

2. Compare the root node with its left and right child nodes.

3. Swap the child node with the smallest/largest value (depending on the type of heap).

4. Repeat steps 2-3 until the heap is sorted.

Example Binary Heap:

0 1 3 2 0 1 2 3 2 3 1 0 0

Step-by-Step Instructions:

  1. Compare 0 with 1 and 3.
  2. Swap 0 with 1.
  3. Compare 0 with 3.
  4. Swap 3 with 0.
  5. ...

What's Next:

Proceed to Heap Sorting Challenge 5: "Heap-pocalypse 2.0"!