CSC297.Java 2003, Class 38: Wrapup Admin: * Cool talk today at noon. Watch Sam fall asleep. * Showing up late the last day is neither nice nor a good idea * Questions on the homework? * I will look at code you email to me, although perhaps not promptly * Questions on the exam? Overview: * What did you learn in this class? * What didn't you learn in this class? * Concluding remarks Yvonne's Homework Questions * How do you handle deletion in AVL trees? * You make sure that you only delete leaves and then you work from there * That means that Sam needs to figure out how to get the alternate version of delete working for BSTs. (He's not sure when he'll write the code, but you'll get it by late tonight.) * Do we have to print the height of each subtree when we dump the tree? * It would be nice. However, if you don't keep track of it, I'll survive without it. * Why would we ever have to do two rotations? * See the example on the board A(n+3) / \ B(n+2) C(n) / \ D(n) E(n+1) / \ F G A(n+3) / \ E(n+2) C(n) / \ B G / \ D F E(n+2) / \ B(n+1) A(n+1) / \ / \ D(n)F G C(n) * How do we keep track of the height of a tree during insertion? Warning! Approximate code! if (compare.mayPrecede(newValue, current.getValue())) { current.left = insert(newValue, current.left); if ((current.left.height - current.right.height) > 1) { ... // rebalance; } } ... current.height = 1 + max(current.left.height, current.right.height); * If we find an implementation on the Web, can we use it? * As long as you understand it and document it. * Warning! Many people post incorrect solutions (purposefully or accidentally) * One more potential exam question: List as much as you can think of that I intended for you to learn this semester /Algorithms/ /ADTs and Data Structures/ /OOP/ /Other/