Question: Write a #build_tree method that takes an array of data ([1, 7, 4, 23, 8, 9, 4, 3, 5, 7, 9, 67, 6345, 324])
Write a #build_tree method that takes an array of data ([1, 7, 4, 23, 8, 9, 4, 3, 5, 7, 9, 67, 6345, 324]) and turns it into a balanced binary tree full of Node objects appropriately placed (don't forget to sort and remove duplicates!). The #build_tree method should return the level-1 root node. Write an #insert and #delete method which accepts a value to insert/delete. . . Display output
Step by Step Solution
There are 3 Steps involved in it
Heres a Ruby implementation of the buildtree method for creating a balanced binary search tree BST f... View full answer
Get step-by-step solutions from verified subject matter experts
