Give the (zero-based level-order indexing) array representation
of the max-heap of characters where indicated. Assume that the
entries are compared in lexicographical order, where A < B
< … < Z. Execute the sequence of operations shown
in the code Listing 1 on an initially empty priority queue, pQHeap,
that uses a binary max-heap. The priority value of each letter is
its position in the alphabet.
Listing 1
1 pQHeap . insert ('S');
2 pQHeap . insert ('Y');
3 pQHeap . insert ('N');
4 pQHeap . insert ('C');
5 pQHeap . insert ('O');
6 pQHeap . delete ();
7 pQHeap . insert ('P');
8 pQHeap . insert ('A');
9 pQHeap . insert ('T');
10 pQHeap . insert ('I');
11 pQHeap . insert ('V');
12 pQHeap . insert ('E');
13 pQHeap . delete ();
Give the array representation of the max-heap after line 5 is
executed (5 blanks)
Give the array representation of the max-heap after line 6 is
executed (4 blanks)
Give the array representation of the max-heap after line 12 is
executed (10 blanks)
Give the array representation of the max-heap after line 13 is
executed (9 blanks)
Give the (zero-based level-order indexing) array representation of the max-heap of characters where indicated. Assume th
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am