Binary tree

Binary tree program in C is a nonlinear data structure used for data search and organization. Binary tree is comprised of nodes, and these nodes each being a data component, have left and right child nodes. Unlike other data structures, such as, Arrays, Stack and queue, Linked List which are Linear type data structures whereas Trees are Hierarchical type of data structures. Binary search tree or BST in short, whose nodes each store keys greater than their left child nodes and less than all the right child nodes. As the data in a binary tree is organized, it allows operations like insertion, deletion, update and fetch. Let us dive deeper into the concepts related to the Binary tree and implement some of the examples using C programming language.
Syntax:
Binary tree does not have any particular Syntax but has an Algorithm to follow in implementing Binary Tree.
struct BT {
int data;
struct BT *rightNode, *leftNode;
};
Left sub tree of node contains nodes with keys less than node’s key
Right sub tree of node contains nodes with keys greater than node’s key
Both left and right sub tree must also be a Binary tree, and no duplicates are allowed.
Illustration of Binary Tree:
Posted on by