Solved

binary  tree

Posted on 2012-04-07
5
344 Views
Last Modified: 2012-06-27
if I start with an empty tree, and then insert 1,2,3, what do I get?  

if I start with an empty tree, and then insert 6,5,4, what do I get?
0
Comment
Question by:HLRosenberger
  • 2
  • 2
5 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37819770
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37819807
You should clarify...what KIND of binary tree?

A "binary tree" is simply one where nodes have no more than two children.

A "binary search tree" (BST) is ORDERED and has rules on how nodes are inserted.

An AVL tree is a self-balancing BST that has additional rules on the difference in depth between two child nodes.

Here's an interactive tree that you can actually see what will happen when those sequences are entered into a standard BST:
http://www.cs.jhu.edu/~goodrich/dsa/trees/btree.html
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 37819840
I've done this stuff before.  Just has been  while.

A binary search tree.  1, 2, 3 would give:   root is 1, right child of 1 is 2, right child of 2 is 3, correct?

6, 5, 4 would give:   root is 6, left child of 6 is 5, left child of 5 is 4, correct?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37819851
That's correct.  Those two sequences are probably for demonstrating that a standard BST is no better than a linked list when the data being inserted is ALREADY SORTED.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 37819950
Thanks!!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question