Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT … · 2015-02-02 · Initially...

Preview:

Citation preview

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Initially the array may not satisfy the heap property.The heap will be built up by calling heapify on all internal nodes from the bottom up.

Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 19 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 19 and its children is node 19.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 18 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 18 and its children is node 18.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 17 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 17 and its children is node 36.Root and max will be swapped and heapify will recurse on the new node 36.

Heap size: 40 Array contents: ALGORITHMS-CAMBRIDGE-2015-HEAPSORT-GS509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: D 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: S 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 36.Heap size: 40 Array contents: ALGORITHMS-CAMBRISGE-2015-HEAPSORT-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 36 and its children is node 36.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMBRISGE-2015-HEAPSORT-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 16 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRISGE-2015-HEAPSORT-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 16 and its children is node 33.Root and max will be swapped and heapify will recurse on the new node 33.

Heap size: 40 Array contents: ALGORITHMS-CAMBRISGE-2015-HEAPSORT-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: I 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: T 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 33.Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 33 and its children is node 33.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 15.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 14 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 14 and its children is node 30.Root and max will be swapped and heapify will recurse on the new node 30.

Heap size: 40 Array contents: ALGORITHMS-CAMBRTSGE-2015-HEAPSORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: B

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: S

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 30.Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 30 and its children is node 30.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 13 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 13 and its children is node 13.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 12 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 12 and its children is node 26.Root and max will be swapped and heapify will recurse on the new node 26.

Heap size: 40 Array contents: ALGORITHMS-CAMSRTSGE-2015-HEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: A 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: H 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 26.Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 26 and its children is node 26.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 11 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 11 and its children is node 11.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 10 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 10 and its children is node 21.Root and max will be swapped and heapify will recurse on the new node 21.

Heap size: 40 Array contents: ALGORITHMS-CHMSRTSGE-2015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: - 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: 2 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 21.Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 21 and its children is node 21.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 9 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 9 and its children is node 9.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 17.Root and max will be swapped and heapify will recurse on the new node 17.

Heap size: 40 Array contents: ALGORITHMS2CHMSRTSGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: M 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: S 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 17.Heap size: 40 Array contents: ALGORITHSS2CHMSRTMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 17 and its children is node 17.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITHSS2CHMSRTMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITHSS2CHMSRTMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 16.Root and max will be swapped and heapify will recurse on the new node 16.

Heap size: 40 Array contents: ALGORITHSS2CHMSRTMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: H 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: T 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 16.Heap size: 40 Array contents: ALGORITTSS2CHMSRHMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: H 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 16 and its children is node 33.Root and max will be swapped and heapify will recurse on the new node 33.

Heap size: 40 Array contents: ALGORITTSS2CHMSRHMGE--015-AEAPBORI-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: H 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: I 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 33.Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 33 and its children is node 33.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 6.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 5.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 9.Root and max will be swapped and heapify will recurse on the new node 9.

Heap size: 40 Array contents: ALGORITTSS2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: R 5: I 6: T

7: T 8: S 9: S 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 9.Heap size: 40 Array contents: ALGOSITTSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: S 5: I 6: T

7: T 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 9 and its children is node 9.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGOSITTSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: S 5: I 6: T

7: T 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGOSITTSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: S 5: I 6: T

7: T 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 40 Array contents: ALGOSITTSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: O 4: S 5: I 6: T

7: T 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 40 Array contents: ALGTSITOSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: O 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 40 Array contents: ALGTSITOSR2CHMSRIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: O 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 40 Array contents: ALGTSITRSR2CHMSOIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: O 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 32.Root and max will be swapped and heapify will recurse on the new node 32.

Heap size: 40 Array contents: ALGTSITRSR2CHMSOIMGE--015-AEAPBORH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: O 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: R 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 32.Heap size: 40 Array contents: ALGTSITRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 32 and its children is node 32.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALGTSITRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALGTSITRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 40 Array contents: ALGTSITRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: G

3: T 4: S 5: I 6: T

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 40 Array contents: ALTTSIGRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: G

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 14.Root and max will be swapped and heapify will recurse on the new node 14.

Heap size: 40 Array contents: ALTTSIGRSR2CHMSRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: G

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: S

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 14.Heap size: 40 Array contents: ALTTSISRSR2CHMGRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: G

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 14 and its children is node 29.Root and max will be swapped and heapify will recurse on the new node 29.

Heap size: 40 Array contents: ALTTSISRSR2CHMGRIMGE--015-AEAPBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: G

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: P 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 29.Heap size: 40 Array contents: ALTTSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 29 and its children is node 29.No swap is necessary, heapify done.

Heap size: 40 Array contents: ALTTSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ALTTSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 40 Array contents: ALTTSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: L 2: T

3: T 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 40 Array contents: ATTLSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: L 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 8.Root and max will be swapped and heapify will recurse on the new node 8.

Heap size: 40 Array contents: ATTLSISRSR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: L 4: S 5: I 6: S

7: R 8: S 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8.Heap size: 40 Array contents: ATTSSISRLR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: L 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 17.Root and max will be swapped and heapify will recurse on the new node 17.

Heap size: 40 Array contents: ATTSSISRLR2CHMPRIMGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: L 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: M 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 17.Heap size: 40 Array contents: ATTSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 17 and its children is node 17.No swap is necessary, heapify done.

Heap size: 40 Array contents: ATTSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the build heap (heap-up) process.Heap size: 40 Array contents: ATTSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 40 Array contents: ATTSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: A

1: T 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 40 Array contents: TATSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: A 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 40 Array contents: TATSSISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: A 2: T

3: S 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 40 Array contents: TSTASISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: A 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 40 Array contents: TSTASISRMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: A 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 40 Array contents: TSTRSISAMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: A 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 40 Array contents: TSTRSISAMR2CHMPRILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: A 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: R 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 40 Array contents: TSTRSISRMR2CHMPAILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: A 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 31.Root and max will be swapped and heapify will recurse on the new node 31.

Heap size: 40 Array contents: TSTRSISRMR2CHMPAILGE--015-AEAGBOOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: A 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: O 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 31.Heap size: 40 Array contents: TSTRSISRMR2CHMPOILGE--015-AEAGBAOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 31 and its children is node 31.No swap is necessary, heapify done.

Heap size: 40 Array contents: TSTRSISRMR2CHMPOILGE--015-AEAGBAOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

The array now satisfies the heap property.The heap will be emptied by repeatedly taking the root element

and moving it outside of the heap in the underlying array.Heap size: 40 Array contents: TSTRSISRMR2CHMPOILGE--015-AEAGBAOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 40 Array contents: TSTRSISRMR2CHMPOILGE--015-AEAGBAOH-GD509

0: T

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0 39: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 39 Array contents: 9STRSISRMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: 9

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 39 Array contents: 9STRSISRMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: 9

1: S 2: T

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 39 Array contents: TS9RSISRMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: 9

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 39 Array contents: TS9RSISRMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: 9

3: R 4: S 5: I 6: S

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 39 Array contents: TSSRSI9RMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: 9

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 14.Root and max will be swapped and heapify will recurse on the new node 14.

Heap size: 39 Array contents: TSSRSI9RMR2CHMPOILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: 9

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: P

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 14.Heap size: 39 Array contents: TSSRSIPRMR2CHM9OILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: 9

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 14 and its children is node 29.Root and max will be swapped and heapify will recurse on the new node 29.

Heap size: 39 Array contents: TSSRSIPRMR2CHM9OILGE--015-AEAGBAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: 9

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: G 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 29.Heap size: 39 Array contents: TSSRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 29 and its children is node 29.No swap is necessary, heapify done.

Heap size: 39 Array contents: TSSRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 39 Array contents: TSSRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD50T

0: T

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5 38: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 38 Array contents: 0SSRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: 0

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 38 Array contents: 0SSRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: 0

1: S 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 38 Array contents: S0SRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: 0 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 4.Root and max will be swapped and heapify will recurse on the new node 4.

Heap size: 38 Array contents: S0SRSIPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: 0 2: S

3: R 4: S 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4.Heap size: 38 Array contents: SSSR0IPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: 0 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 9.Root and max will be swapped and heapify will recurse on the new node 9.

Heap size: 38 Array contents: SSSR0IPRMR2CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: 0 5: I 6: P

7: R 8: M 9: R 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 9.Heap size: 38 Array contents: SSSRRIPRM02CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: 0 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 9 and its children is node 19.Root and max will be swapped and heapify will recurse on the new node 19.

Heap size: 38 Array contents: SSSRRIPRM02CHMGOILGE--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: 0 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: E 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 19.Heap size: 38 Array contents: SSSRRIPRME2CHMGOILG0--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 19 and its children is node 19.No swap is necessary, heapify done.

Heap size: 38 Array contents: SSSRRIPRME2CHMGOILG0--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 38 Array contents: SSSRRIPRME2CHMGOILG0--015-AEA9BAOH-GD5TT

0: S

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D 37: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 37 Array contents: 5SSRRIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: 5

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 37 Array contents: 5SSRRIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: 5

1: S 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 37 Array contents: S5SRRIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: 5 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 37 Array contents: S5SRRIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: 5 2: S

3: R 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 37 Array contents: SRS5RIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: 5 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 37 Array contents: SRS5RIPRME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: 5 4: R 5: I 6: P

7: R 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 37 Array contents: SRSRRIP5ME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: 5 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 37 Array contents: SRSRRIP5ME2CHMGOILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: 5 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 37 Array contents: SRSRRIPOME2CHMG5ILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: 5 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 32.Root and max will be swapped and heapify will recurse on the new node 32.

Heap size: 37 Array contents: SRSRRIPOME2CHMG5ILG0--015-AEA9BAOH-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: 5 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: O 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 32.Heap size: 37 Array contents: SRSRRIPOME2CHMGOILG0--015-AEA9BA5H-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 32 and its children is node 32.No swap is necessary, heapify done.

Heap size: 37 Array contents: SRSRRIPOME2CHMGOILG0--015-AEA9BA5H-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 37 Array contents: SRSRRIPOME2CHMGOILG0--015-AEA9BA5H-GDSTT

0: S

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G 36: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 36 Array contents: DRSRRIPOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: D

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 36 Array contents: DRSRRIPOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: D

1: R 2: S

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 36 Array contents: SRDRRIPOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: D

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 36 Array contents: SRDRRIPOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: D

3: R 4: R 5: I 6: P

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 36 Array contents: SRPRRIDOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: D

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 13.Root and max will be swapped and heapify will recurse on the new node 13.

Heap size: 36 Array contents: SRPRRIDOME2CHMGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: D

7: O 8: M 9: E 10: 2 11: C 12: H 13: M 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 13.Heap size: 36 Array contents: SRPRRIMOME2CHDGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: D 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 13 and its children is node 27.Root and max will be swapped and heapify will recurse on the new node 27.

Heap size: 36 Array contents: SRPRRIMOME2CHDGOILG0--015-AEA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: D 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: E 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 27.Heap size: 36 Array contents: SRPRRIMOME2CHEGOILG0--015-ADA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 27 and its children is node 27.No swap is necessary, heapify done.

Heap size: 36 Array contents: SRPRRIMOME2CHEGOILG0--015-ADA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 36 Array contents: SRPRRIMOME2CHEGOILG0--015-ADA9BA5H-GSSTT

0: S

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: - 35: G

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 35 Array contents: GRPRRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: G

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 35 Array contents: GRPRRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: G

1: R 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 35 Array contents: RGPRRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: G 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 35 Array contents: RGPRRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: G 2: P

3: R 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 35 Array contents: RRPGRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: G 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 35 Array contents: RRPGRIMOME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: G 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 35 Array contents: RRPORIMGME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: O 4: R 5: I 6: M

7: G 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 35 Array contents: RRPORIMGME2CHEGOILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: O 4: R 5: I 6: M

7: G 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: O 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 35 Array contents: RRPORIMOME2CHEGGILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 15.No swap is necessary, heapify done.

Heap size: 35 Array contents: RRPORIMOME2CHEGGILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 35 Array contents: RRPORIMOME2CHEGGILG0--015-ADA9BA5H-SSSTT

0: R

1: R 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H 34: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 34 Array contents: -RPORIMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: -

1: R 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 34 Array contents: -RPORIMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: -

1: R 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 34 Array contents: R-PORIMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: - 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 4.Root and max will be swapped and heapify will recurse on the new node 4.

Heap size: 34 Array contents: R-PORIMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: - 2: P

3: O 4: R 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4.Heap size: 34 Array contents: RRPO-IMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: - 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 9.Root and max will be swapped and heapify will recurse on the new node 9.

Heap size: 34 Array contents: RRPO-IMOME2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: - 5: I 6: M

7: O 8: M 9: E 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 9.Heap size: 34 Array contents: RRPOEIMOM-2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: - 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 9 and its children is node 19.Root and max will be swapped and heapify will recurse on the new node 19.

Heap size: 34 Array contents: RRPOEIMOM-2CHEGGILG0--015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: - 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: 0 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 19.Heap size: 34 Array contents: RRPOEIMOM02CHEGGILG---015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 19 and its children is node 19.No swap is necessary, heapify done.

Heap size: 34 Array contents: RRPOEIMOM02CHEGGILG---015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 34 Array contents: RRPOEIMOM02CHEGGILG---015-ADA9BA5HRSSSTT

0: R

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5 33: H

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 33 Array contents: HRPOEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: H

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 33 Array contents: HRPOEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: H

1: R 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 33 Array contents: RHPOEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: H 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 33 Array contents: RHPOEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: H 2: P

3: O 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 33 Array contents: ROPHEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: H 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 33 Array contents: ROPHEIMOM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: H 4: E 5: I 6: M

7: O 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 33 Array contents: ROPOEIMHM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: O 4: E 5: I 6: M

7: H 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 16.Root and max will be swapped and heapify will recurse on the new node 16.

Heap size: 33 Array contents: ROPOEIMHM02CHEGGILG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: O 4: E 5: I 6: M

7: H 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: I 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 16.Heap size: 33 Array contents: ROPOEIMIM02CHEGGHLG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 16 and its children is node 16.No swap is necessary, heapify done.

Heap size: 33 Array contents: ROPOEIMIM02CHEGGHLG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 33 Array contents: ROPOEIMIM02CHEGGHLG---015-ADA9BA5RRSSSTT

0: R

1: O 2: P

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A 32: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 32 Array contents: 5OPOEIMIM02CHEGGHLG---015-ADA9BARRRSSSTT

0: 5

1: O 2: P

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 32 Array contents: 5OPOEIMIM02CHEGGHLG---015-ADA9BARRRSSSTT

0: 5

1: O 2: P

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 32 Array contents: PO5OEIMIM02CHEGGHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: 5

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 32 Array contents: PO5OEIMIM02CHEGGHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: 5

3: O 4: E 5: I 6: M

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 32 Array contents: POMOEI5IM02CHEGGHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: 5

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 14.Root and max will be swapped and heapify will recurse on the new node 14.

Heap size: 32 Array contents: POMOEI5IM02CHEGGHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: 5

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: G

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 14.Heap size: 32 Array contents: POMOEIGIM02CHE5GHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: 5

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 14 and its children is node 30.Root and max will be swapped and heapify will recurse on the new node 30.

Heap size: 32 Array contents: POMOEIGIM02CHE5GHLG---015-ADA9BARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: 5

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: B

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 30.Heap size: 32 Array contents: POMOEIGIM02CHEBGHLG---015-ADA95ARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 30 and its children is node 30.No swap is necessary, heapify done.

Heap size: 32 Array contents: POMOEIGIM02CHEBGHLG---015-ADA95ARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 32 Array contents: POMOEIGIM02CHEBGHLG---015-ADA95ARRRSSSTT

0: P

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

31: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 31 Array contents: AOMOEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: A

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 31 Array contents: AOMOEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: A

1: O 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 31 Array contents: OAMOEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: A 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 31 Array contents: OAMOEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: A 2: M

3: O 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 31 Array contents: OOMAEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: A 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 8.Root and max will be swapped and heapify will recurse on the new node 8.

Heap size: 31 Array contents: OOMAEIGIM02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: A 4: E 5: I 6: G

7: I 8: M 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8.Heap size: 31 Array contents: OOMMEIGIA02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: A 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 17.Root and max will be swapped and heapify will recurse on the new node 17.

Heap size: 31 Array contents: OOMMEIGIA02CHEBGHLG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: A 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: L 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 17.Heap size: 31 Array contents: OOMMEIGIL02CHEBGHAG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 17 and its children is node 17.No swap is necessary, heapify done.

Heap size: 31 Array contents: OOMMEIGIL02CHEBGHAG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 31 Array contents: OOMMEIGIL02CHEBGHAG---015-ADA95PRRRSSSTT

0: O

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9 30: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 30 Array contents: 5OMMEIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: 5

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 30 Array contents: 5OMMEIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: 5

1: O 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 30 Array contents: O5MMEIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: 5 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 30 Array contents: O5MMEIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: 5 2: M

3: M 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 30 Array contents: OMM5EIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: 5 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 8.Root and max will be swapped and heapify will recurse on the new node 8.

Heap size: 30 Array contents: OMM5EIGIL02CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: 5 4: E 5: I 6: G

7: I 8: L 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8.Heap size: 30 Array contents: OMMLEIGI502CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: 5 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 18.Root and max will be swapped and heapify will recurse on the new node 18.

Heap size: 30 Array contents: OMMLEIGI502CHEBGHAG---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: 5 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: G 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 18.Heap size: 30 Array contents: OMMLEIGIG02CHEBGHA5---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 18 and its children is node 18.No swap is necessary, heapify done.

Heap size: 30 Array contents: OMMLEIGIG02CHEBGHA5---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 30 Array contents: OMMLEIGIG02CHEBGHA5---015-ADA9OPRRRSSSTT

0: O

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A 29: 9

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 29 Array contents: 9MMLEIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: 9

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 29 Array contents: 9MMLEIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: 9

1: M 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 29 Array contents: M9MLEIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: 9 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 29 Array contents: M9MLEIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: 9 2: M

3: L 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 29 Array contents: MLM9EIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: 9 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 29 Array contents: MLM9EIGIG02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: 9 4: E 5: I 6: G

7: I 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 29 Array contents: MLMIEIG9G02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: I 4: E 5: I 6: G

7: 9 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 16.Root and max will be swapped and heapify will recurse on the new node 16.

Heap size: 29 Array contents: MLMIEIG9G02CHEBGHA5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: I 4: E 5: I 6: G

7: 9 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: H 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 16.Heap size: 29 Array contents: MLMIEIGHG02CHEBG9A5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 16 and its children is node 16.No swap is necessary, heapify done.

Heap size: 29 Array contents: MLMIEIGHG02CHEBG9A5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 29 Array contents: MLMIEIGHG02CHEBG9A5---015-ADAOOPRRRSSSTT

0: M

1: L 2: M

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D 28: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 28 Array contents: ALMIEIGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: A

1: L 2: M

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 28 Array contents: ALMIEIGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: A

1: L 2: M

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 28 Array contents: MLAIEIGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: A

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 5.Root and max will be swapped and heapify will recurse on the new node 5.

Heap size: 28 Array contents: MLAIEIGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: A

3: I 4: E 5: I 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5.Heap size: 28 Array contents: MLIIEAGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: I

3: I 4: E 5: A 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 12.Root and max will be swapped and heapify will recurse on the new node 12.

Heap size: 28 Array contents: MLIIEAGHG02CHEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: I

3: I 4: E 5: A 6: G

7: H 8: G 9: 0 10: 2 11: C 12: H 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 12.Heap size: 28 Array contents: MLIIEHGHG02CAEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 12 and its children is node 12.No swap is necessary, heapify done.

Heap size: 28 Array contents: MLIIEHGHG02CAEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 28 Array contents: MLIIEHGHG02CAEBG9A5---015-ADMOOPRRRSSSTT

0: M

1: L 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A 27: D

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 27 Array contents: DLIIEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: D

1: L 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 27 Array contents: DLIIEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: D

1: L 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 27 Array contents: LDIIEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: D 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 27 Array contents: LDIIEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: D 2: I

3: I 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 27 Array contents: LIIDEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: D 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 27 Array contents: LIIDEHGHG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: D 4: E 5: H 6: G

7: H 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 27 Array contents: LIIHEHGDG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: H 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 27 Array contents: LIIHEHGDG02CAEBG9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: H 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: G 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 27 Array contents: LIIHEHGGG02CAEBD9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 15.No swap is necessary, heapify done.

Heap size: 27 Array contents: LIIHEHGGG02CAEBD9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 27 Array contents: LIIHEHGGG02CAEBD9A5---015-AMMOOPRRRSSSTT

0: L

1: I 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: - 26: A

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 26 Array contents: AIIHEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: A

1: I 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 26 Array contents: AIIHEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: A

1: I 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 26 Array contents: IAIHEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: A 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 26 Array contents: IAIHEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: A 2: I

3: H 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 26 Array contents: IHIAEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: A 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 26 Array contents: IHIAEHGGG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: A 4: E 5: H 6: G

7: G 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 26 Array contents: IHIGEHGAG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: G 4: E 5: H 6: G

7: A 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 26 Array contents: IHIGEHGAG02CAEBD9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: G 4: E 5: H 6: G

7: A 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: D 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 26 Array contents: IHIGEHGDG02CAEBA9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 15.No swap is necessary, heapify done.

Heap size: 26 Array contents: IHIGEHGDG02CAEBA9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 26 Array contents: IHIGEHGDG02CAEBA9A5---015-LMMOOPRRRSSSTT

0: I

1: H 2: I

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5 25: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 25 Array contents: -HIGEHGDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: -

1: H 2: I

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 25 Array contents: -HIGEHGDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: -

1: H 2: I

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 25 Array contents: IH-GEHGDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: -

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 5.Root and max will be swapped and heapify will recurse on the new node 5.

Heap size: 25 Array contents: IH-GEHGDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: -

3: G 4: E 5: H 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5.Heap size: 25 Array contents: IHHGE-GDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: - 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 11.Root and max will be swapped and heapify will recurse on the new node 11.

Heap size: 25 Array contents: IHHGE-GDG02CAEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: - 6: G

7: D 8: G 9: 0 10: 2 11: C 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 11.Heap size: 25 Array contents: IHHGECGDG02-AEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: - 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 11 and its children is node 24.Root and max will be swapped and heapify will recurse on the new node 24.

Heap size: 25 Array contents: IHHGECGDG02-AEBA9A5---015ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: - 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 24.Heap size: 25 Array contents: IHHGECGDG025AEBA9A5---01-ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 24 and its children is node 24.No swap is necessary, heapify done.

Heap size: 25 Array contents: IHHGECGDG025AEBA9A5---01-ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 25 Array contents: IHHGECGDG025AEBA9A5---01-ILMMOOPRRRSSSTT

0: I

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1 24: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 24 Array contents: -HHGECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: -

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 24 Array contents: -HHGECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: -

1: H 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 24 Array contents: H-HGECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: - 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 24 Array contents: H-HGECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: - 2: H

3: G 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 24 Array contents: HGH-ECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: - 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 8.Root and max will be swapped and heapify will recurse on the new node 8.

Heap size: 24 Array contents: HGH-ECGDG025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: - 4: E 5: C 6: G

7: D 8: G 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8.Heap size: 24 Array contents: HGHGECGD-025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: - 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 17.Root and max will be swapped and heapify will recurse on the new node 17.

Heap size: 24 Array contents: HGHGECGD-025AEBA9A5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: - 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: A 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 17.Heap size: 24 Array contents: HGHGECGDA025AEBA9-5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 17 and its children is node 17.No swap is necessary, heapify done.

Heap size: 24 Array contents: HGHGECGDA025AEBA9-5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 24 Array contents: HGHGECGDA025AEBA9-5---01IILMMOOPRRRSSSTT

0: H

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0 23: 1

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 23 Array contents: 1GHGECGDA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: 1

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 23 Array contents: 1GHGECGDA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: 1

1: G 2: H

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 23 Array contents: HG1GECGDA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: 1

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 23 Array contents: HG1GECGDA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: 1

3: G 4: E 5: C 6: G

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 23 Array contents: HGGGEC1DA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: G

3: G 4: E 5: C 6: 1

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 13.Root and max will be swapped and heapify will recurse on the new node 13.

Heap size: 23 Array contents: HGGGEC1DA025AEBA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: G

3: G 4: E 5: C 6: 1

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: E 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 13.Heap size: 23 Array contents: HGGGECEDA025A1BA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 13 and its children is node 13.No swap is necessary, heapify done.

Heap size: 23 Array contents: HGGGECEDA025A1BA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 23 Array contents: HGGGECEDA025A1BA9-5---0HIILMMOOPRRRSSSTT

0: H

1: G 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: - 22: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 22 Array contents: 0GGGECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: 0

1: G 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 22 Array contents: 0GGGECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: 0

1: G 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 22 Array contents: G0GGECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: 0 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 22 Array contents: G0GGECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: 0 2: G

3: G 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 22 Array contents: GGG0ECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: 0 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 22 Array contents: GGG0ECEDA025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: 0 4: E 5: C 6: E

7: D 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 22 Array contents: GGGDECE0A025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: D 4: E 5: C 6: E

7: 0 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 15.Root and max will be swapped and heapify will recurse on the new node 15.

Heap size: 22 Array contents: GGGDECE0A025A1BA9-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: D 4: E 5: C 6: E

7: 0 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: A 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 15.Heap size: 22 Array contents: GGGDECEAA025A1B09-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 15 and its children is node 15.No swap is necessary, heapify done.

Heap size: 22 Array contents: GGGDECEAA025A1B09-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 22 Array contents: GGGDECEAA025A1B09-5---HHIILMMOOPRRRSSSTT

0: G

1: G 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: - 21: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 21 Array contents: -GGDECEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: -

1: G 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 21 Array contents: -GGDECEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: -

1: G 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 21 Array contents: G-GDECEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: - 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 4.Root and max will be swapped and heapify will recurse on the new node 4.

Heap size: 21 Array contents: G-GDECEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: - 2: G

3: D 4: E 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4.Heap size: 21 Array contents: GEGD-CEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: E 2: G

3: D 4: - 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 10.Root and max will be swapped and heapify will recurse on the new node 10.

Heap size: 21 Array contents: GEGD-CEAA025A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: E 2: G

3: D 4: - 5: C 6: E

7: A 8: A 9: 0 10: 2 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 10.Heap size: 21 Array contents: GEGD2CEAA0-5A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: E 2: G

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 10 and its children is node 10.No swap is necessary, heapify done.

Heap size: 21 Array contents: GEGD2CEAA0-5A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: E 2: G

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 21 Array contents: GEGD2CEAA0-5A1B09-5--GHHIILMMOOPRRRSSSTT

0: G

1: E 2: G

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: - 20: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 20 Array contents: -EGD2CEAA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: -

1: E 2: G

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 20 Array contents: -EGD2CEAA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: -

1: E 2: G

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 20 Array contents: GE-D2CEAA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: -

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 20 Array contents: GE-D2CEAA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: -

3: D 4: 2 5: C 6: E

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 20 Array contents: GEED2C-AA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: E

3: D 4: 2 5: C 6: -

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 14.Root and max will be swapped and heapify will recurse on the new node 14.

Heap size: 20 Array contents: GEED2C-AA0-5A1B09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: E

3: D 4: 2 5: C 6: -

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: B

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 14.Heap size: 20 Array contents: GEED2CBAA0-5A1-09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 14 and its children is node 14.No swap is necessary, heapify done.

Heap size: 20 Array contents: GEED2CBAA0-5A1-09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 20 Array contents: GEED2CBAA0-5A1-09-5-GGHHIILMMOOPRRRSSSTT

0: G

1: E 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5 19: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 19 Array contents: -EED2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: -

1: E 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 19 Array contents: -EED2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: -

1: E 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 19 Array contents: E-ED2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: - 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 19 Array contents: E-ED2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: - 2: E

3: D 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 19 Array contents: EDE-2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: - 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 19 Array contents: EDE-2CBAA0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: - 4: 2 5: C 6: B

7: A 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 19 Array contents: EDEA2CB-A0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: A 4: 2 5: C 6: B

7: - 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 16.Root and max will be swapped and heapify will recurse on the new node 16.

Heap size: 19 Array contents: EDEA2CB-A0-5A1-09-5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: A 4: 2 5: C 6: B

7: - 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: 9 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 16.Heap size: 19 Array contents: EDEA2CB9A0-5A1-0--5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 16 and its children is node 16.No swap is necessary, heapify done.

Heap size: 19 Array contents: EDEA2CB9A0-5A1-0--5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 19 Array contents: EDEA2CB9A0-5A1-0--5GGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: E

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: - 18: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 18 Array contents: 5DEA2CB9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: 5

1: D 2: E

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 18 Array contents: 5DEA2CB9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: 5

1: D 2: E

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 18 Array contents: ED5A2CB9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: 5

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 5.Root and max will be swapped and heapify will recurse on the new node 5.

Heap size: 18 Array contents: ED5A2CB9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: 5

3: A 4: 2 5: C 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5.Heap size: 18 Array contents: EDCA25B9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: C

3: A 4: 2 5: 5 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 12.Root and max will be swapped and heapify will recurse on the new node 12.

Heap size: 18 Array contents: EDCA25B9A0-5A1-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: C

3: A 4: 2 5: 5 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: A 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 12.Heap size: 18 Array contents: EDCA2AB9A0-551-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 12 and its children is node 12.No swap is necessary, heapify done.

Heap size: 18 Array contents: EDCA2AB9A0-551-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 18 Array contents: EDCA2AB9A0-551-0--EGGGHHIILMMOOPRRRSSSTT

0: E

1: D 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: - 17: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 17 Array contents: -DCA2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: -

1: D 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 17 Array contents: -DCA2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: -

1: D 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 17 Array contents: D-CA2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: - 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 17 Array contents: D-CA2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: - 2: C

3: A 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 17 Array contents: DAC-2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: A 2: C

3: - 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 8.Root and max will be swapped and heapify will recurse on the new node 8.

Heap size: 17 Array contents: DAC-2AB9A0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: A 2: C

3: - 4: 2 5: A 6: B

7: 9 8: A 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 8.Heap size: 17 Array contents: DACA2AB9-0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: A 2: C

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 8 and its children is node 8.No swap is necessary, heapify done.

Heap size: 17 Array contents: DACA2AB9-0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: A 2: C

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 17 Array contents: DACA2AB9-0-551-0-EEGGGHHIILMMOOPRRRSSSTT

0: D

1: A 2: C

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0 16: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 16 Array contents: -ACA2AB9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: C

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 16 Array contents: -ACA2AB9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: C

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 16 Array contents: CA-A2AB9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: -

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 16 Array contents: CA-A2AB9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: -

3: A 4: 2 5: A 6: B

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 16 Array contents: CABA2A-9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: B

3: A 4: 2 5: A 6: -

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 13.Root and max will be swapped and heapify will recurse on the new node 13.

Heap size: 16 Array contents: CABA2A-9-0-551-0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: B

3: A 4: 2 5: A 6: -

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: 1 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 13.Heap size: 16 Array contents: CABA2A19-0-55--0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: B

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 13 and its children is node 13.No swap is necessary, heapify done.

Heap size: 16 Array contents: CABA2A19-0-55--0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: B

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 16 Array contents: CABA2A19-0-55--0DEEGGGHHIILMMOOPRRRSSSTT

0: C

1: A 2: B

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

15: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 15 Array contents: 0ABA2A19-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: A 2: B

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 15 Array contents: 0ABA2A19-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: A 2: B

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 15 Array contents: BA0A2A19-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: 0

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 5.Root and max will be swapped and heapify will recurse on the new node 5.

Heap size: 15 Array contents: BA0A2A19-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: 0

3: A 4: 2 5: A 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5.Heap size: 15 Array contents: BAAA2019-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: A

3: A 4: 2 5: 0 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 11.Root and max will be swapped and heapify will recurse on the new node 11.

Heap size: 15 Array contents: BAAA2019-0-55--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: A

3: A 4: 2 5: 0 6: 1

7: 9 8: - 9: 0 10: - 11: 5 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 11.Heap size: 15 Array contents: BAAA2519-0-05--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 11 and its children is node 11.No swap is necessary, heapify done.

Heap size: 15 Array contents: BAAA2519-0-05--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 15 Array contents: BAAA2519-0-05--CDEEGGGHHIILMMOOPRRRSSSTT

0: B

1: A 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: - 14: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 14 Array contents: -AAA2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 14 Array contents: -AAA2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 14 Array contents: A-AA2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: - 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 14 Array contents: A-AA2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: - 2: A

3: A 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 14 Array contents: AAA-2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: A 2: A

3: - 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 7.Root and max will be swapped and heapify will recurse on the new node 7.

Heap size: 14 Array contents: AAA-2519-0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: A 2: A

3: - 4: 2 5: 5 6: 1

7: 9 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 7.Heap size: 14 Array contents: AAA9251--0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: A 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 7 and its children is node 7.No swap is necessary, heapify done.

Heap size: 14 Array contents: AAA9251--0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: A 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 14 Array contents: AAA9251--0-05-BCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: A 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5 13: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 13 Array contents: -AA9251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 13 Array contents: -AA9251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: A 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 13 Array contents: A-A9251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: - 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 3.Root and max will be swapped and heapify will recurse on the new node 3.

Heap size: 13 Array contents: A-A9251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: - 2: A

3: 9 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 3.Heap size: 13 Array contents: A9A-251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: A

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 3 and its children is node 3.No swap is necessary, heapify done.

Heap size: 13 Array contents: A9A-251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: A

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 13 Array contents: A9A-251--0-05ABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: A

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0 12: 5

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 12 Array contents: 59A-251--0-0AABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 9 2: A

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 12 Array contents: 59A-251--0-0AABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 9 2: A

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 12 Array contents: A95-251--0-0AABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 2.No swap is necessary, heapify done.

Heap size: 12 Array contents: A95-251--0-0AABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 12 Array contents: A95-251--0-0AABCDEEGGGHHIILMMOOPRRRSSSTT

0: A

1: 9 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: - 11: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 11 Array contents: 095-251--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: 9 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 11 Array contents: 095-251--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: 9 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 11 Array contents: 905-251--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 9

1: 0 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 4.Root and max will be swapped and heapify will recurse on the new node 4.

Heap size: 11 Array contents: 905-251--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 9

1: 0 2: 5

3: - 4: 2 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4.Heap size: 11 Array contents: 925-051--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 9

1: 2 2: 5

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 4.No swap is necessary, heapify done.

Heap size: 11 Array contents: 925-051--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 9

1: 2 2: 5

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 11 Array contents: 925-051--0-AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 9

1: 2 2: 5

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0 10: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 10 Array contents: -25-051--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 2 2: 5

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 10 Array contents: -25-051--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 2 2: 5

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 10 Array contents: 52--051--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: -

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 5.Root and max will be swapped and heapify will recurse on the new node 5.

Heap size: 10 Array contents: 52--051--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: -

3: - 4: 0 5: 5 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 5.Heap size: 10 Array contents: 525-0-1--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 5

3: - 4: 0 5: - 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 5 and its children is node 5.No swap is necessary, heapify done.

Heap size: 10 Array contents: 525-0-1--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 5

3: - 4: 0 5: - 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 10 Array contents: 525-0-1--09AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 5

3: - 4: 0 5: - 6: 1

7: - 8: - 9: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 9 Array contents: 025-0-1--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: 2 2: 5

3: - 4: 0 5: - 6: 1

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 9 Array contents: 025-0-1--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: 2 2: 5

3: - 4: 0 5: - 6: 1

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 9 Array contents: 520-0-1--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 0

3: - 4: 0 5: - 6: 1

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 9 Array contents: 520-0-1--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 0

3: - 4: 0 5: - 6: 1

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 9 Array contents: 521-0-0--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 1

3: - 4: 0 5: - 6: 0

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 6.No swap is necessary, heapify done.

Heap size: 9 Array contents: 521-0-0--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 1

3: - 4: 0 5: - 6: 0

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 9 Array contents: 521-0-0--59AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 5

1: 2 2: 1

3: - 4: 0 5: - 6: 0

7: - 8: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 8 Array contents: -21-0-0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 2 2: 1

3: - 4: 0 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 8 Array contents: -21-0-0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 2 2: 1

3: - 4: 0 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 8 Array contents: 2-1-0-0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 2

1: - 2: 1

3: - 4: 0 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 4.Root and max will be swapped and heapify will recurse on the new node 4.

Heap size: 8 Array contents: 2-1-0-0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 2

1: - 2: 1

3: - 4: 0 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 4.Heap size: 8 Array contents: 201---0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 2

1: 0 2: 1

3: - 4: - 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 4 and its children is node 4.No swap is necessary, heapify done.

Heap size: 8 Array contents: 201---0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 2

1: 0 2: 1

3: - 4: - 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 8 Array contents: 201---0-559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 2

1: 0 2: 1

3: - 4: - 5: - 6: 0

7: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 7 Array contents: -01---02559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 0 2: 1

3: - 4: - 5: - 6: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 7 Array contents: -01---02559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 0 2: 1

3: - 4: - 5: - 6: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 7 Array contents: 10----02559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 1

1: 0 2: -

3: - 4: - 5: - 6: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 6.Root and max will be swapped and heapify will recurse on the new node 6.

Heap size: 7 Array contents: 10----02559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 1

1: 0 2: -

3: - 4: - 5: - 6: 0

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 6.Heap size: 7 Array contents: 100----2559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 1

1: 0 2: 0

3: - 4: - 5: - 6: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 6 and its children is node 6.No swap is necessary, heapify done.

Heap size: 7 Array contents: 100----2559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 1

1: 0 2: 0

3: - 4: - 5: - 6: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 7 Array contents: 100----2559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 1

1: 0 2: 0

3: - 4: - 5: - 6: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 6 Array contents: -00---12559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 0 2: 0

3: - 4: - 5: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 1.Root and max will be swapped and heapify will recurse on the new node 1.

Heap size: 6 Array contents: -00---12559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: 0 2: 0

3: - 4: - 5: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 1.Heap size: 6 Array contents: 0-0---12559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: 0

3: - 4: - 5: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 1 and its children is node 1.No swap is necessary, heapify done.

Heap size: 6 Array contents: 0-0---12559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: 0

3: - 4: - 5: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 6 Array contents: 0-0---12559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: 0

3: - 4: - 5: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 5 Array contents: --0--012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: 0

3: - 4: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 2.Root and max will be swapped and heapify will recurse on the new node 2.

Heap size: 5 Array contents: --0--012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: 0

3: - 4: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 2.Heap size: 5 Array contents: 0----012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: -

3: - 4: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 2 and its children is node 2.No swap is necessary, heapify done.

Heap size: 5 Array contents: 0----012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: -

3: - 4: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 5 Array contents: 0----012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: 0

1: - 2: -

3: - 4: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 4 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

3: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 0.No swap is necessary, heapify done.

Heap size: 4 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

3: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 4 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

3: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 3 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 0.No swap is necessary, heapify done.

Heap size: 3 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 3 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: - 2: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 2 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 0.No swap is necessary, heapify done.

Heap size: 2 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Removing root and moving it outside of the heap.The last element takes its place and the heap size is decremented.

Heap size: 2 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

1: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Running heapify on node 0 as part of the repair heap (heap-down) process.Heap size: 1 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Largest of node 0 and its children is node 0.No swap is necessary, heapify done.

Heap size: 1 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

0: -

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Heap empty, sorting complete.Heap size: 0 Array contents: ----0012559AAABCDEEGGGHHIILMMOOPRRRSSSTT

Recommended