Overview
Welcome to 4th Quarter! Since this is a class filled with soon-to-be graduating seniors, we will have less time to finish what we still need to accomplish, so let's get right to it!
Wednesday, April 23rd
Next Project and Project Pairs
Our task will be to implement a binary search tree in Ruby. You will work in the following pairs to complete this project:
- Anar and Adonis
- Akshay and Cody
- Luis and Mulbah
- Ved and Turner
- Jamethiel and Caleb
- Isaac and Marin
- Anfal and Trostin
- Parker and Johan
These pairs were not random, but were instead intentionally choosen by me as
clique breakers
with an eye toward combating Senioritis and enhancing
productivity. We'll see how well I did ;-)
BSTs with Paper and Pencil
We want to create a BinarySearchTree
class with the following
methods:
insert(value)
: Inserts a value into the BSTsearch(value)
: Returns true if value exists in the treedelete(value)
: Removes a value from the treein_order_traversal
: Returns array of values in sorted orderpre_order_traversal
: Returns array in root-left-right orderpost_order_traversal
: Returns array in left-right-root ordermin
: Returns the minimum valuemax
: Returns the maximum valueheight
: Returns the height of the tree- empty?: Returns true if tree has no nodes
Before you can implement these in code, you should practice doing them on paper by hand. We will use class time today to do just that.