Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Need an algorithm for creating an complete binary tree.

Reply
Thread Tools

Need an algorithm for creating an complete binary tree.

 
 
C-man
Guest
Posts: n/a
 
      03-04-2004
Yeah, for some reason I can seem to find an algorithm that will simple but
items into the tree in fashion such that a new leaf can't be added to a new
level till all the leafs at the previous level are used. This would seem
like an easy solution but I couldn't find one and I only could get it
parsley working. Any body of a solution?


Thanks


 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      03-04-2004
"C-man" <(E-Mail Removed)> wrote in message
newsgv1c.39622$n17.16894@clgrps13...
> Yeah, for some reason I can seem to find an algorithm that will simple but
> items into the tree in fashion such that a new leaf can't be added to a

new
> level till all the leafs at the previous level are used. This would seem
> like an easy solution but I couldn't find one and I only could get it
> parsley working. Any body of a solution?


Algorithms aren't topical here. Just the ISO standard C++ language.
See: http://www.slack.net/~shiva/welcome.txt

However:
http://www.google.com/search?hl=en&i...ry+tree%22+alg
orithm+%22C%2B%2B%22&btnG=Google+Search
(that'll probably wrap, just paste it back together)

Over 7,000 hits.

You might want to try asking about this in an algorithms group
or mailing list.

-Mike


 
Reply With Quote
 
 
 
 
Dietmar Kuehl
Guest
Posts: n/a
 
      03-04-2004
"C-man" <(E-Mail Removed)> wrote:
> Yeah, for some reason I can seem to find an algorithm that will simple but
> items into the tree in fashion such that a new leaf can't be added to a new
> level till all the leafs at the previous level are used. This would seem
> like an easy solution but I couldn't find one and I only could get it
> parsley working. Any body of a solution?


What is your actual goal? Typically, for something like a search tree it is
sufficient that the tree is reasonably balanced. For example, if the
maximum height in each (sub)tree is at most twice the minimum height, you
will get logarithmic access to all operations. And the corresponding
condition is relatively easy to maintain using AVL- or Red-Black-Trees.

The simplest approach to a fully balanced binary tree is probably using an
array in the first place! You would use 'std::lower_bound()' to locate a
position - be it for insertion or lookup. The container is, in this case,
of course not node bound.
--
<(E-Mail Removed)> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
This algorithm written in Python solves at least a subset of theHamilton Circuit problem, which is NP complete, in n^3 time. Martin Python 0 03-20-2011 03:54 AM
Filtered Back Projection Algorithm (FBP Algorithm) Bapaiah Katepalli VHDL 1 06-23-2006 04:50 PM
Binary to thermometric algorithm vishallko31@gmail.com VHDL 6 06-15-2006 08:50 AM
algorithm - how to estimate time to complete worzel Java 8 03-03-2005 02:44 PM
Key generation algorithm and Cipher algorithm Ahmed Moustafa Java 0 11-15-2003 06:35 AM



Advertisments