Examveda

Select the code snippet which performs post-order traversal.

A.

public void postorder(Tree root)
{
	System.out.println(root.data);
	postorder(root.left);
	postorder(root.right);
}

B.

public void postorder(Tree root)
{
	postorder(root.left);
	postorder(root.right);
	System.out.println(root.data);
}

C.

public void postorder(Tree root)
{
	System.out.println(root.data);
	postorder(root.right);
	postorder(root.left);
}

D.

public void postorder(Tree root)
{
	postorder(root.right);
        System.out.println(root.data);
	postorder(root.left);
}

Answer: Option B


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

Join The Discussion

Related Questions on Binary Search Trees(B Tree)