BUILD-MAX-HEAP, the worked problem
  input A = [5 13 2 25 7 17 20 8 4 11]
  MAX-HEAPIFY(A, 5)  node value 7
      swap A[5]=7 with A[10]=11
    A = [5 13 2 25 11 17 20 8 4 7]
  MAX-HEAPIFY(A, 4)  node value 25
    A = [5 13 2 25 11 17 20 8 4 7]
  MAX-HEAPIFY(A, 3)  node value 2
      swap A[3]=2 with A[7]=20
    A = [5 13 20 25 11 17 2 8 4 7]
  MAX-HEAPIFY(A, 2)  node value 13
      swap A[2]=13 with A[4]=25
    A = [5 25 20 13 11 17 2 8 4 7]
  MAX-HEAPIFY(A, 1)  node value 5
      swap A[1]=5 with A[2]=25
      swap A[2]=5 with A[4]=13
      swap A[4]=5 with A[8]=8
    A = [25 13 20 8 11 17 2 5 4 7]
  result is a max-heap: yes   comparisons = 15, swaps = 6

BUILD-MAX-HEAP, the check-yourself array
  input A = [3 9 2 1 4 5]
  MAX-HEAPIFY(A, 3)  node value 2
      swap A[3]=2 with A[6]=5
    A = [3 9 5 1 4 2]
  MAX-HEAPIFY(A, 2)  node value 9
    A = [3 9 5 1 4 2]
  MAX-HEAPIFY(A, 1)  node value 3
      swap A[1]=3 with A[2]=9
      swap A[2]=3 with A[5]=4
    A = [9 4 5 1 3 2]
  result is a max-heap: yes   comparisons = 7, swaps = 3

HEAPSORT on the worked array
  after extracting 25: [20 13 17 8 11 7 2 5 4 25]   heap-size = 9
  after extracting 20: [17 13 7 8 11 4 2 5 20 25]   heap-size = 8
  after extracting 17: [13 11 7 8 5 4 2 17 20 25]   heap-size = 7
  after extracting 13: [11 8 7 2 5 4 13 17 20 25]   heap-size = 6
  after extracting 11: [8 5 7 2 4 11 13 17 20 25]   heap-size = 5
  after extracting  8: [7 5 4 2 8 11 13 17 20 25]   heap-size = 4
  after extracting  7: [5 2 4 7 8 11 13 17 20 25]   heap-size = 3
  after extracting  5: [4 2 5 7 8 11 13 17 20 25]   heap-size = 2
  after extracting  4: [2 4 5 7 8 11 13 17 20 25]   heap-size = 1
  sorted: [2 4 5 7 8 11 13 17 20 25]

The linear bound: swaps made by BUILD-MAX-HEAP on n = 2^k - 1 keys in
ascending order (every value must sink as far as it can)
      n     swaps    n - lg(n+1)
      7         4              4
     63        57             57
    511       502            502
   4095      4083           4083
  32767     32752          32752
