Examveda

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


This Question Belongs to Data Structure >> Binary Search Trees(B Tree)

Join The Discussion

Related Questions on Binary Search Trees(B Tree)