Professional Documents
Culture Documents
Presentation 1
Presentation 1
TO
Kainat
Hafsa
Esha
Binary Search Tree (BST):
A binary search tree is a rooted binary tree
in which the nodes are arranged in strict
total order in which the nodes with keys
greater than any particular node is stored
on the right sub-trees and the ones with
equal to or less than are stored on the left
sub-tree satisfying the binary search
property.
Binary search tree is a data structure that quickly allows
us to maintain a sorted list of numbers.
It is called a binary tree because each tree node has a maximum of
two children.
It is called a search tree because it can be used to search for the
presence of a number in O(log(n)) time
Non-leaf nodes are also known as parent
nodes as they have more than 0 child and
less than two children.
In this case, replace the node with its child and delete the child node,
which now contains the value which is to be deleted. Simply replace
it with the NULL and free the allocated space.
In the following image, the node 12 is to be deleted. It has only one
child. The node will be replaced with its child node and the replaced
node 12 (which is now leaf node) will simply be deleted.
In the following image, the node 50 is to be deleted which is
the root node of the tree. The in-order traversal of the tree
given below.