How will you find the maximum element in a binary search tree?
A.
public void max(Tree root)
{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}
B.
public void max(Tree root)
{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}
C.
public void max(Tree root)
{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}
D.
public void max(Tree root)
{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}
Answer: Option C
Join The Discussion