Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

FIRST REVIEW

BINARY SEARCH
TREE

Submitted By
swan
INTRODUCTION
The bibary search tree  has the following properties.
 The left sub tree  of a node contains only nodes with keys
less than the node's key. The right sub tree of a node contains
only nodes with keys greater than the node's key.Both the left
and right sub trees must also be binary search trees.
Generally, the information represented by each node is
a record rather than a single data element..
The major advantage of binary search trees over other data
structures is that the related sorting algorithms  and search
algorithms  such as in-order traversal can be very
efficient.Binary search trees are a fundamental data structure
 used to construct more abstract data structures such
as sets , multisets , and associative arrays .
MODULES
1. INSERTION
2. DELETION
3. SEARCHING
INSERTION
Insertion begins as a search would begin;
 If the root is not equal to the value, we search the left
or right subtrees as before.
Eventually, we will reach an external node and add the
value as its right or left child, depending on the node's
value.
In other words, we examine the root and recursively
insert the new node to the left subtree .
If the new value is less than the root, or the right subtree
if the new value is greater than or equal to the root.
DELETION
Deleting a leaf (node with no children): Deleting a leaf is
easy, as we can simply remove it from the tree.
Deleting a node with one child: Remove the node and
replace it with its child.
Deleting a node with two children: Call the node to be
deleted N. Do not delete N. Instead, choose either its in-
order successor node or its in-order predecessor node, R.
Replace the value of N with the value of R, then delete R.
As with all binary trees, a node's in-order successor is the
left-most child of its right subtree, and a node's in-order
predecessor is the right-most child of its left subtree. In
either case, this node will have zero or one children. Delete
it according to one of the two simpler cases above.
SEARCHING
Searching a binary tree for a specific value can be a recursive
 or iterative  process. This explanation covers a recursive
method.
We begin by examining the root node .
If the tree is null, the value we are searching for does not exist in
the tree.
Otherwise, if the value equals the root, the search is successful.
If the value is less than the root, search the left subtree.
If it is greater than the root, search the right subtree. This
process is repeated until the value is found or the indicated
subtree is null. If the searched value is not found before a null
subtree is reached, then the item must not be present in the tree.
EXISTING SYSTEM
In existing system we have the code for binary search
tree.But in the existing system it is very difficult to
understand about the various functions in binary
search tree insertion, searching and deletion as the
graphics display is not used in the existing system. The
existing system is not much user friendly and it is very
difficult for a user to work with it. 
PROPOSED SYSTEM
In our proposed system we have binary search tree
with searching, insertion and deletion. We are building
binary seaech tree with c++ program by using
graphics display.by using graphics display it is
becoming more user frirendly and its more easy to
understand for a user.different colors are used for
searching the numbers for easy to understand.
DESIGN
START

Print”MENU/n1.INSE
RT/n2.PRINT
TREE/n3. DELETE /n
4.SEARCH/n5.EXIT/n

Read choice

If
(choice==1
)

If
Insertval() (choice==2
)

B
Printtree()

A
B
A

If
(choice==3
)

Deleteval()
If
(choice==4
)

If
(choice==5
Search() )

Main()

Exit(0)

STOP
start insertval()

Read the element,val

if
(root==NUL
L)

root=val

if
(val<root
)

insertval()
if
(val>roo
t)

insertval()

Print val

stop
start search()

Read the element to


be searched,val

if
(root==va
l)

print root

if
(root<val
)

A B
A B

search()

if
(val>root
)

search()

print “search value not found”

stop
THANK YOU

You might also like