The Gateway to Computer Science Excellence
+1 vote
93 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
edited by | 93 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

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
52,223 questions
59,811 answers
201,020 comments
118,087 users