binary trees

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2004
Posts: 3
Reputation: cuperman is an unknown quantity at this point 
Solved Threads: 0
cuperman cuperman is offline Offline
Newbie Poster

binary trees

 
0
  #1
Oct 31st, 2004
i've referred a couple of datastructure books and both give different definitions for width of a binary tree.
one says its the no of nodes at a level,while another says its the longest path that can be traversed in a binary tree.
can any one help me with a recursive /non recursive algorithm for the second one?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 10
Reputation: kunal_ktr is an unknown quantity at this point 
Solved Threads: 0
kunal_ktr kunal_ktr is offline Offline
Newbie Poster

Re: binary trees

 
0
  #2
Oct 31st, 2004
recursive algorithm :
height(tree * ){
if(root==NULL)
return 0;
return 1+max(height(root->left),height(root->right));
}

hope u can write a function for max(par1, par2) also. ok
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: binary trees

 
0
  #3
Oct 31st, 2004
Generally, a binary tree is a collection of nodes, each with one 'parent' and two 'children', a 'left' child and a 'right' child. In addition, there would be some data or payload.

But from there, folks specialize them in all kinds of ways. For example, 'red/black' trees; search Google for various types of binary trees and their algorithms.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC