Do the following problems:
-
Page 132, 6.2-1
Using Figure 6.2 as a model, illustrate
the operation of MAX-HEAPIFY(A, 3)
on the array
A={27, 17, 3, 16, 13, 10, 1, 5, 7,
12, 4, 8, 9, 0}.
-
Page 135, 6.3-1
Using Figure 6.3 as a model, illustrate
the operation of BUILD-MAX-HEAP
on the array
A={5, 3, 17, 10, 84, 19, 6, 22, 9}.
-
Page 136, 6.4-1
Using Figure 6.4 as a model, illustrate
the operation of HEAPSORT on the
array
A={5, 13, 2, 25, 7, 17, 20, 8, 4}.
-
Page 140, 6.5-1
Illustrate the operation of HEAP-EXTRACT-MAX
on the heap
A={15, 13, 9, 5, 12, 8, 7, 4, 0, 6,
2, 1}.
-
Page 140, 6.5-2
Illustrate the operation of MAX-HEAP-INSERT(A,
10) on the heap
A={15, 13, 9, 5, 12, 8, 7, 4, 0, 6,
2, 1}.
Use the heap of Figure 6,5 as a model for
the HEAP-INCREASE-KEY call.
-
Page 140, 6.5-7
The operation HEAP-DELETE(A,
i)
deletes the item in node i from heap A.
Give an implementation of HEAP-DELETE
that runs in O(lgn)
time for an n-element max-heap.
-
Page 148, 7.1-1
Using Figure 7.1 as a model, illustrate
the operation of PARTITION on the
array
A={13, 19, 9, 5, 12, 8, 7, 4, 11,
2, 6, 21}.
-
Page 170, 8.2-1
Using Figure 8.2 as a model, illustrate
the operation of COUNTING-SORT
on the array
A={6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}.
-
Page 170, 8.2-3
Suppose that the for loop header in line 9 of the COUNTING-SORT
procedure is rewritten as
9 for j <-- 1
to length[A]
Show that the algorithm still works properly.
Is modified algorithm stable?
-
Page 173, 8.3-1
Using Figure 8.3 as a model, illustrate
the operation of RADIX-SORT on
the following list of English words:
COW, DOG, SEA, RUG, ROW, MOB, BOX,
TAB, BAR, EAR, TAR, DIG, BIG, TEA, NOW, FOX.