Algorithm for finding maximum of a binary search tree

19 Views Asked by At

To find the maximum of a BST I thought that it would be sufficient to start at the root node and then check if it has a right child (The left child is not relevant since every left subtree of a node has smaller entries than the node itself). Then repeat the process until there is no more right child. The final node is the maximum.

Is this correct?

I also need to determine the worst case complexity for this algorithm. This should be if the maximum is at the end of the BST so the complexity would be $O(h)$ where $h$ is the height of the BST.

I also need to find a refinement of BSTs so that this complexity can be reduced however I don't have a clue how to this.

Thanks for any help!