Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

binary search tree

Posted on 2000-04-26
5
Medium Priority
?
313 Views
Last Modified: 2013-11-15
                                         70
                                             \
                                               \
                                              80
                                           /      \
                                         /          \
                                       85        100
                                      /  \          /   \
                                    /     \        /      \
                                 65     88    90     110

my question is this a binary search tree?? i say no, am i right?

given the level of every node, what is the height of the tree?
0
Comment
Question by:beachbumm
[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
5 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 2752563
It's a binary tree. I would be inclined to indicate whether the tree can be USED for searching or not. To use a tree for searching (efficiently) the tree must be ordered. That requires that all nodes to the right of any particular node be "greater" and all nodes to the left be "lesser" than the that node (where greater and lesser could be defined in various ways, in the general case, depending on the data that is being used).
This tree fails that criterion in that 65 is to the right of 70, as is 80. One is less, the other is more, so the tree is not in order.
If it is in order, then when you are searching for a particular node, you can easily determine which node to inspect next, depending on whether the node you want is greater or lesser than the one you are currently considering.

The height would appear to be 4.
0
 

Author Comment

by:beachbumm
ID: 2752667
i agree with you that this is not a binary search tree but when i state the level of every node and height is this 1,2,3,3,4,4,4,4; 4 or is it 0,1,2,2,3,3,3,3; 4?
0
 
LVL 5

Accepted Solution

by:
Jan Louwerens earned 30 total points
ID: 2752705
the height of the tree is 4.
the levels of each node are (top down, left to right) 1,2,3,3,4,4,4,4
0
 
LVL 1

Expert Comment

by:mournblade
ID: 2752708
looks like homework questions to me...

all your questions are so simple and academic in nature: you should read your C++ and Data structures books more carefully. all those answers can be found in any beginners' books about these subjects...
0
 

Author Comment

by:beachbumm
ID: 2752778
comment about these being homework questions...i am 30 and by far not in school, but do take that as a compliment! im self teaching myself the C language as to one day be able to write programs for the business i own. these questions are exercises out of a book and sometimes i need assistance in how the answer is achieved for my own knowledge.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

636 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