Previous Lecture Lecture 16 Next Lecture

Lecture 16, Thu 05/23

Trees, Priority Queues, Heaps

Slides folder

Lecture 15 information was recorded and sent out via the Canvas announcement

Plan for today

Identifying types of trees - Iclicker

Question 1: What kind of tree is it?

(see the slides for an example)

**A. Binary**
B. Balanced
C. Complete
D. Skeleton
E. None of the above

Question 2: What kind of tree is it?

(see the slides for an example)

**A. Binary**
B. Balanced
C. Complete
D. Imbalanced
E. None of the above

Question 3: What kind of tree is it?

(see the slides for an example)

A. Binary
**B. Balanced**
C. Complete
D. Imbalanced
E. None of the above

Question 4: What kind of tree is it?

(see the slides for an example)

A. Binary
B. Balanced
C. Complete
D. Imbalanced
E. None of the above

Question 5: What kind of tree is it?

(see the slides for an example)

A. Binary
B. Balanced
C. Complete
D. Imbalanced
E. None of the above

Question 6: What kind of tree is it?

(see the slides for an example)

A. Binary
B. Balanced
**C. Complete**
D. Tree-like
E. None of the above

Question 7: What kind of tree is it?

(see the slides for an example)

A. Binary
**B. Balanced**
C. Complete
D. Tree-like
E. None of the above

Question 8: Which tree property allowed us to implement a heap as a Python list?

A. Binary
B. Balanced
**C. Complete**
D. None of the above

Binary Heaps

Binary Heap Structure Property:

Heap Order Property:

Binary Heap Insertion Visualization: refer to lecture slides for a visual representation of the heap

Resulting list is: 0 88 80 63 75 59 13 38 25 52 50

Delete the root (88) from the heap above.

Resulting list is: 0 80 75 63 52 59 13 38 25 50

Question: Does the insertion order of the elements affect the structure of the tree?

Practice inserting the elements and either perculating up (during the insertion) or perculating down (during the deletion).