April 30, 2012
Binary Search Trees, how do you find maximum?
Question by Rachel Moss
I’ve been working with Binary Search Trees in my spare time, and I want to be able to delete nodes from a tree.
In order to get this to work, I need to find the maximum value. How do you go about doing that? Pseudo-code or hints would be appreciated. I’m stuck and not exactly sure how to even begin this.
Answer by Starx
A simple pseudocode would be this. It it is indepandant to binary search I think.
int maxi = 0
foreach(array as item) // or any other loop
if item>maxi then maxi = item