Solved

binary  tree

Posted on 2012-04-07
5
347 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 20

Expert Comment

by:BuggyCoder
ID: 37819770
0
 
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 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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