Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

binary  tree

Posted on 2012-04-07
5
Medium Priority
?
351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

730 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