binary tree

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?
LVL 1
HLRosenbergerAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
HLRosenbergerAuthor Commented:
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
 
HLRosenbergerAuthor Commented:
Thanks!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.