The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
72 views

A.  Total no. of trees that were there in the forest.

B. Total no. of nodes in the forest.

C. Total no. of nodes which have only right child.

D. Return max element among all nodes.

in Programming by (143 points)
edited by | 72 views
0
I think C) is the correct answer
0
C should be wrong answer.

But in the question, if they mentioned " it is arbitrary tree represented by right child pointers ", then option A is correct.

I hope this question from ACE.
0

 Shaik Masthan 

can you explain me ??

 

 

+1
just take the Binary tree,

root is A, left of root is B and right of root is C

left of B is D and right of D is E, and E right is F, F right child is G,  G right child is H

right of C is J

What is the answer by you? ( as you said it is 5 due to D have only right child, E have only right child,F have only right child, G have only right child, and C have only right child, )

 

If you apply the algorithm, what is Answer? only 3.
0
but why it's  traverse the right child only ???
0

but why it's  traverse the right child only ???

it is algorithm, you can have your own algorithm 

0
Question is really good .but if this question come in gate I definitely tick option  C

but tell me one thing it's also hold .option C right ???
0
i already gave one example, why option C is wrong.

1 Answer

+3 votes
According to the given algorithm it just calculates total no of right child of right sub tree only which doesnt matches with any of the options given.
by Active (1.7k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,309 questions
55,747 answers
192,248 comments
90,541 users