Professional Documents
Culture Documents
Basic Terminology,
Threaded binary tree- Creation and Traversal of In-order Threaded Binary tree.
TREES:
Definition: A tree data structure is a hierarchical data structure that consists of nodes
connected by edges.
Widely used in computer science for organizing and storing data efficiently.
Nodes:
Edges:
all the nodes along the path from root to that node
Descendant of a node
Subtree:
Binary Trees:
A special type of tree where each node can have two, zero, one children.
Common operations: Insertion, deletion, and traversal (in-order, pre-order, post-
order).
Balanced trees: Height is kept minimal, ensuring efficient operations (e.g., AVL trees,
Red-Black trees).
Unbalanced trees: Height can be significantly larger, leading to slower operations.
Applications:
Disadvantages:
Binary tree:
A special type of tree where each node can have two, zero, one children. which are
referred to as the left child and the right child. which are referred to as the left child
and the right child.
OR
Full binary tree in which except leaf nodes all nodes should have two offspring
A Full binary tree of depth K is a binary tree of depth having 2k-1 nodes k>=0
Then,
These are those skewed binary trees in which all the nodes are having a left child or
no child at all. It is a left side dominated tree. All the right child
These are those skewed binary trees in which all the nodes are having a right child
or no child at all. It is a right side dominated tree. All the left children remain as null.
Right sibling of node in general tree=right most child of node binary tree
Binary Tree Traversals:
1. Depth First Search or DFS
▪In a depth first traversal all the nodes on a branch are visited before any others
are visited
Binary Search Tree is a node-based binary tree data structure that has the following
properties:
The left subtree of a node contains only nodes with keys lesser than the node’s
key.
The right subtree of a node contains only nodes with keys greater than the node’s
key.
This means everything to the left of the root is less than the value of the root and
everything to the right of the root is greater than the value of the root. Due to
this performing, a binary search is very easy.
The left and right subtree each must also be a binary search tree.
There must be no duplicate nodes(BST may have duplicate values with different
handling approaches)