























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























The tree is a nonlinear hierarchical data
structure and comprises a collection of
entities known as nodes. It connects each
node in the tree data structure using
"edges”, both directed and undirected.
In the tree in data structures, the node that is the
predecessor of any node is known as a parent
node, or a node with a branch from itself to any
other successive node is called the parent node
The node, a descendant of any node, is known as
child nodes in data structures.
In a tree, any number of parent nodes can have
any number of child nodes.
Trees in the data structure, the node with no child,
is known as a leaf node.
leaf nodes are also called external nodes or
terminal nodes.
In a tree data structure, the number of edges from
the leaf node to the particular node in the longest
path is known as the height of that node.
A complete binary tree is just like a full
binary tree, but with two major differences
Every level must be completely filled and all
the leaf elements must lean towards the left
and the last leaf element might not have a
right sibling i.e. a complete binary tree
doesn't have to be a full binary tree.
A perfect binary tree is a type of binary tree
in which every internal node has exactly two
child nodes and all the leaf nodes are at the
same level.
A binary tree in which for each node, value
of all the nodes in left subtree is lesser or
equal and value of all the nodes in right
subtree is greater.
That is the field to store data.
There is one field which is pointer to node.
Node asterisk means pointer to node.
This definition of node is very similar to
definition of node for doubly linked list.
And here in the main function, we will have to
write statement like root equal insert and the
arguments.
This root is already a pointer to node so its
address can be collected in a pointer to pointer.
Creating empty tree and code to test the logic, ask
user to enter a number and If number is found,
print "FOUND"
We wanted to insert and in the main function we
are building this link.
Insert the data in BST, return address of root node.
If tree is empty, we can simply create a new node
and set it as root.
if data to be inserted is lesser, insert in left
subtree.
else, insert in right subtree.