[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


V (Binary Trees) Building a binary search tree Develop...

<< Back to: comp.graphics.algorithms Frequently Asked Questions

Question by hiba
Submitted on 11/26/2005
Related FAQ: comp.graphics.algorithms Frequently Asked Questions
Rating: Not yet rated Rate this question: Vote
V (Binary Trees)

Building a binary search tree
Develop a program that takes a user-defined array of integers and outputs a binary tree
for which every node’s left child is less than the right child. As an example, if the user
has entered the following array: (5, 10, 3, 13, 22, 6, 21, 17), the output binary tree should
look like the one in Figure 1. Draw your binary tree with nodes (circles) in red and the
5
3 10
17
6 13
22
21
Figure 1: Binary Tree.
integer values inside in blue. Make sure your graphics look very neat and tidy.
Inserting Nodes dynamically into a binary search tree
Develop a program that will insert a new node with an integer value into a binary search
tree with the same properties as in Figure 1. The user should be able to see immediately
the new location of the node in the binary tree. Make the color of the newly inserted node
green so as to distinguish it from the others. Once another node is inserted, bring the
color of the previously inserted node back to red.
Deleting Nodes dynamically from a binary search tree
Develop a program that will apply deletion by merging method to delete a node from a
binary search tree. The user should be able to select the node to be deleted by clicking
on it with the mouse.
Note: You can combine that program with the program mentioned in the above section
(Inserting Nodes. . . ) and give the user the possibility either to add or to delete a node.
Balancing a tree
Develop a program that will create a balanced tree (where nodes contain integer values)
using the DSW algorithm as described in the textbook. The steps of the program are as
follows:
• The user enters initially an array of integer values.
• Once the array is entered, the program should create a balanced tree using the DSW
algorithm.
• The user should be allowed to insert or delete a node from the previously balanced
tree. Each time a node is inserted/deleted, apply the methods described for AVL
trees in order to re-balance the tree. The tree should be re-drawn on the screen after
re-balancing.
2


Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: comp.graphics.algorithms Frequently Asked Questions


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.