Takeaways
- Given n nodes, the height of the tree is O(logn) ("good tree") or O(N-1) ("bad tree")
- Preorder, inorder, and Postorder are all ways to navigate a BST in O(n) time
- Inserting, Removal and Searching for a value in a "good" BST is O(logn)
- Inserting, Removal and Searching for a value in a "bad" BST is O(n)
- We will talk about a way to guarantee a balance tree, so you can assume you always will be working with a "good" tree
- If you need a dynamic data structure for an application that does many search queries, a BST is an excellent choice
Code
January 30th code represents a BST that holds integers. It is important that you understand how the insert() method works. You can download the zip, extract it, and then import project with your IDE.