3.2.5 Assume we are given the option to insert the search keys in any order we like and that we are aware of how frequently a BST will need to access them. Should the keys be added to the tree in a different order, or in order of decreasing likelihood of access? Describe your response. 3.2.6 Add the tree's height-calculating method height() to BST. Create two implementations: a recursive method that adds a field to each node in the tree and takes linear space and constant time every query, and a method similar to size() that takes linear space and constant time per query.
3.2.5 Assume we are given the option to insert the search keys in any order we like and that we are aware of how frequently a BST will need to access them.
Should the keys be added to the tree in a different order, or in order of decreasing likelihood of access? Describe your response.
3.2.6 Add the tree's height-calculating method height() to BST. Create two implementations: a recursive method that adds a field to each node in the tree and takes linear space and constant time every query, and a method similar to size() that takes linear space and constant time per query.
3.2.5 Assume we are given the option to insert the search keys in any order we like and that we are aware of how frequently a BST will need to access them.
Should the keys be added to the tree in a different order, or in order of decreasing likelihood of access? Describe your response.
3.2.6 Add the tree's height-calculating method height() to BST. Create two implementations: a recursive method that adds a field to each node in the tree and takes linear space and constant time every query, and a method similar to size() that takes linear space and constant time per query.
Step by step
Solved in 4 steps