Google Answers Logo
View Question
Q: algorithm problems: balanced binary search tree for storing integers ( No Answer,   0 Comments )
Subject: algorithm problems: balanced binary search tree for storing integers
Category: Computers > Algorithms
Asked by: levymoshe-ga
List Price: $20.00
Posted: 22 Mar 2006 07:32 PST
Expires: 22 Mar 2006 08:40 PST
Question ID: 710534
do the following problem:
Implement a balanced binary search tree for storing integers - either
a red-black tree or a 2-3 tree. The program should interactively take
input from the user, accepting the following commands, which trigger
the given actions:

i 5 - inserts the value 5 (or whatever number the user gives) into the tree. 
s 5 - searches for the value 5 (or whatever), and reports yes if the
value is in the tree, or no if it is not.
d 5 - search for the value, and if it is in the tree deletes the value
and reports done, or reports not there otherwise.
p - do inorder traversal, printing out all stored values. 
h - report the height of the root (i.e., the length of the longest
path from the root to a leaf).
c - report the number of nodes in the tree (c is for count). 
q - quit the program. 

Don't quit until the q command is received. 

When printing the inorder traversal, print the values in a way that
shows the structure of the tree. One easy way to do this is to wrap
parentheses around all values in each subtree (including the entire
tree). For example, the 2-3 tree in the middle right of Figure 6.8 on
page 216 (after inserting all numbers except 7) would look like this:

((2) 3 (4 5) 8 (9))

If you implement a red-black tree, be sure to distinguish between red
and black nodes somehow, perhaps by putting asterisks around the black

Clarification of Question by levymoshe-ga on 22 Mar 2006 07:39 PST
There is no answer at this time.

There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy