GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Placement Papers  >  Adobe
Next Question 
 Adobe  |  Question 1 of 2    Print  
An N-ary tree has N sub-nodes for each node, it has M non-leaf nodes
Find the no of leaf nodes?

  
Total Answers and Comments: 12 Last Update: September 18, 2007     Asked by: D Sridhar 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
April 28, 2006 13:38:37   #1  
vishal singla        

RE: An N-ary tree has N sub-nodes for each node, it ha...
this is a standard theorm you can search on net(N+1)(M-1)
 
Is this answer useful? Yes | No
May 05, 2006 13:29:51   #2  
Bharat Sarda        

RE: An N-ary tree has N sub-nodes for each node, it ha...
Correct Answer is :  (n - 1)×m + 1
 
Is this answer useful? Yes | No
June 27, 2006 08:10:45   #3  
Divya        

RE: An N-ary tree has N sub-nodes for each node, it ha...

Hi,

Can anybody tell me what are the questions which are asked in ADOBE written test ?????


 
Is this answer useful? Yes | No
August 11, 2006 02:11:10   #4  
ramesh kumar        

RE: An N-ary tree has N sub-nodes for each node, it ha...

ans:m+1

exp: consider binary tree that having depth x


 
Is this answer useful? Yes | No
August 19, 2006 11:16:28   #5  
jeeves        

RE: An N-ary tree has N sub-nodes for each node, it ha...
N^(logMtobaseN)
 
Is this answer useful? Yes | No
September 05, 2006 01:05:09   #6  
neelimadahiya Member Since: September 2006   Contribution: 1    

RE: An N-ary tree has N sub-nodes for each node, it ha...

Well, I have an answer with the explanation:

consider a N-ary tree with depth d

Total no of nodes in the tree, T=1+N+N^2+...+N^d= (1-N^(d+1))/(1-N) --(1)

No. of non leaf nodes, M=(1-N^d)/(1-N) ---(2)

No. of leaf nodes = T-M = N^d ---(3)

from eq (2), d= log(base N) [MN-M+1] ---(4)

Therefore, no of leaf nodes = N^d = MN-M+1


 
Is this answer useful? Yes | No
September 17, 2006 00:36:19   #7  
Nav        

RE: An N-ary tree has N sub-nodes for each node, it ha...

Yep, the answer is ((1 - N^(h-1)) / ( 1 - N)) + M

where,
N: N-ary tree
h: Height of N-ary tree
M: No of leaf nodes

Example:

Suppose we are having 3-nary tree as shown below:


(h:1)                                                                                 (1)


(h:2)                                         ((2)                          (3)                    (4))


(h:3)                ((5)                   (6)            (7))
   ((8)  (9) (10))  ((11)  (12)  (13))


(h:4)    ((14)  (15)  (16))  ((17))     <-------- M (i.e. 4) Leaf Nodes

Here,
N: 3-ary tree
h: 4, Height of 3-ary tree
M: 4, No of leaf nodes

Now, Apply the formaula:

= ((1 - 3^(4-1)) / ( 1 - 3)) + 4

= 17
Hence Proved.

Solution by:

The Revolutions (Comp Sci RnD)
A Orkut's Community
http://www.orkut.com/Community.aspx?cmm=13552733

Yahoo Group
http://www.yahoogroups.com/group/TheRevolutions


 
Is this answer useful? Yes | No
September 21, 2006 09:15:24   #8  
Vishnu Priya        

RE: An N-ary tree has N sub-nodes for each node, it ha...
it is (M-1)*N
 
Is this answer useful? Yes | No
March 29, 2007 05:32:13   #9  
vibhu        

RE: An N-ary tree has N sub-nodes for each node, it ha...
yes its M*(N-1)+1
 
Is this answer useful? Yes | No
April 18, 2007 03:34:41   #10  
abhishek        

RE: An N-ary tree has N sub-nodes for each node, it ha...
Let total height of N-ary tree == i
According to question leaf nodes exists only at last level , i.e at ith level
so
N^0 + N^1 + ...............+ N^(i-1) = M
on solving this , we get :
N^(i) = M(N-1) + 1
which is equal to total no. of  leaf nodes

 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
Go To Top


 Sponsored Links

 
Related Categories
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape