944,123 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3677
  • C RSS
Oct 31st, 2004
0

binary trees

Expand Post »
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cuperman is offline Offline
3 posts
since Oct 2004
Oct 31st, 2004
0

Re: binary trees

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kunal_ktr is offline Offline
10 posts
since Oct 2004
Oct 31st, 2004
0

Re: binary trees

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.
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C Forum Timeline: Need help with small beginner program, please.
Next Thread in C Forum Timeline: unfamiliar parameter specified





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC