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

x
Solved

# insert into binary tree

Posted on 2012-04-07
Medium Priority
318 Views
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
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

LVL 38

Expert Comment

ID: 37820167
Hi, this depends on your insert algorithm or what kind of binary tree you are building. Inserting odd to the left and even to the right, your trees would look like this:

1
/ \
3   2

6
/ \
5   4

What kind of insert algorithm are you using / what is the purpose of the tree?
0

LVL 32

Accepted Solution

phoffric earned 2000 total points
ID: 37821501
It could be:
1
\
2
\
3
(Unbalanced search tree)

or

1
/\
2   3
(Balanced search tree)

- depends on the algorithm used to insert.
The balanced tree will have faster retrieval times because the depth of the tree is usually less than an unbalanced tree.
0

LVL 1

Author Closing Comment

ID: 37823723
Thanks. UNbalanced.
0

LVL 38

Expert Comment

ID: 37823814
I would have appreciated a reply on my questions before accepting another experts' comment as a solution ;)
0

## Featured Post

Question has a verified solution.

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

Introduction On a scale of 1 to 10, how would you rate our Product? Many of us have answered that question time and time again. But only a few of us have had the pleasure of receiving a stack of the filled out surveys and being asked to do somethi…
Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
###### Suggested Courses
Course of the Month9 days, 16 hours left to enroll

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

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