Data Structures :: Searching & Sorting - Discussion
Home > Data Structures > Searching & Sorting > MCQs Questions Discussion
65 / 69
Choose the correct option.
How will you find the maximum element in a binary search tree?
Case I:
public void max(Tree root)
{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}
Case II:
public void max(Tree root)
{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}
Case III:
public void max(Tree root)
{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}
Case IV:
public void max(Tree root)
{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}
How will you find the maximum element in a binary search tree?
Case I:
public void max(Tree root)
{
while(root.left() != null)
{
root = root.left();
}
System.out.println(root.data());
}
Case II:
public void max(Tree root)
{
while(root != null)
{
root = root.left();
}
System.out.println(root.data());
}
Case III:
public void max(Tree root)
{
while(root.right() != null)
{
root = root.right();
}
System.out.println(root.data());
}
Case IV:
public void max(Tree root)
{
while(root != null)
{
root = root.right();
}
System.out.println(root.data());
}
ACase I
BCase II
CCase III
DCase IV
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
No Discussion on this question yet!