views:

37

answers:

2

I was asked to build a binary search tree after adding about 20 values in a specific order and I finished and found the size to be 16 and the height to be 4. But part (c) of the question asks me to find the Height (after removal) I am unsure what this means and would be grateful if somebody could clarify what this means.

A: 

"After removal" suggests you were also asked to remove a value. If you weren't asked about any particular value, pick one (or several) to try. Does the height of the tree change after you remove an element?

VoteyDisciple
A: 

I think there are two different phases, first you create an empty binary tree, you add the elements (some gets discarded because dupes or what? how did they become 16 from 20?). Then you remove some elements and you need to know height after this removal?

To retrieve height you can use an easy recursive function, just think that the height of a generic non-leaf node is the maximum between children heights + 1..

Jack