Lecture 7 Objectives
At the end of today's class you should
KNOW:
- That well-designed object-oriented programs rely on dynamic dispatch
rather than on explicitly checking object types
- Why an additional invariant is needed for the BST to ensure improved
worst-case performance over a list for the hasElt operation
- That an AVL tree is BST for which the heights of the two subtrees of
any given node differ by at most 1
BE ABLE TO:
- Explain the advantages of using dynamic dispatch over the use
of instanceof
- Rewrite a method that uses instanceof
in a way that relies on dymamic dispatch instead
- Identify trees as binary trees, binary search trees, AVL trees
Sample Exam Question:
In a short, well-written paragraph, explain why the worst-case performance
for hasElt() when a set is implemented as a BST is no better than the
worst-case performance for hasElt() when a set is implemented as a list.