[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

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());
}

ACase I

BCase II

CCase III

DCase IV

Answer: Option (Login/Signup)

Show Explanation

Asked In :: Capgemini

Post Your Answer Here:     

No Discussion on this question yet!