Tree

Trees

Trees Definitions: Binary Tree:  A binary tree is either empty or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root. Node:  Each element of a binary tree is called a node of a tree. Father:  If A is the root …

Trees Read More »

Program to implement In-Threaded Binary Tree

In-Threaded-Binary Tree Program to implement In-Threaded Binary Tree: /*In-threaded Binary Tree*/ #include <stdio.h> #include <conio.h> #include <stdlib.h> typedef struct threadedbinarytree { int info; struct threadedbinarytree *left,*right; int lflag,rflag; }tbt; tbt *create(); tbt *makenode(int); tbt *insert(tbt *,tbt *); int inorderSuccessor(tbt *,tbt *); int inorderPredecessor(tbt *,tbt *); void traverseInorder(tbt *); /*Allocate memory*/ tbt *create() { tbt *temp=(tbt …

Program to implement In-Threaded Binary Tree Read More »

Program to implement Right-In-Threaded Binary Tree

Right-In-Threaded Binary Tree Program to implement Right-In-Threaded Binary Tree: /*Right In Threaded Binary Tree*/ #include <stdio.h> #include <conio.h> #include <stdlib.h> typedef struct threadedbinarytree {int info; struct threadedbinarytree *left,*right; int rlink; }TBT; TBT *create(); TBT *makenode(int); TBT *insert(TBT *,TBT *); /*inorder or symmetric order*/ void inorder(TBT *); /*Depth first order*/ void preorder(TBT *); TBT *create() { …

Program to implement Right-In-Threaded Binary Tree Read More »

Program to implement Left-In-Threaded Binary Tree

Left-In-Threaded Binary Tree Program to implement Left-In-Threaded Binary Tree: /*Left In Threaded Binary Tree*/ #include <stdio.h> #include <conio.h> #include <stdlib.h> typedef struct threadedbinarytree {int info; struct threadedbinarytree *left,*right; int lflag; }TBT; TBT *create(); TBT *makenode(int); TBT *insert(TBT *,TBT *); void traverseDescending(TBT *); TBT *create() { TBT *temp=(TBT *)malloc(sizeof(TBT)); if(temp==NULL) {printf(“Memory Allocation Error!”); exit(1); } return …

Program to implement Left-In-Threaded Binary Tree Read More »

Program to implement various operations on a Binary Search Tree

Binary Search Tree: Program to implement various operations on Binary Search Tree: /*Binary Search Tree*/ #include <stdio.h> #include <alloc.h> #include <conio.h> #include <stdlib.h> #define MAX 10 /* -OPERATIONS- (i) Creation of a Binary Search Tree (ii) Traversal a) Preorder – Recursive/Iterative b) Inorder – Recursive/Iterative c) Postorder – Recursive/Iterative d) Level by Level (iii) Insertion …

Program to implement various operations on a Binary Search Tree Read More »

You cannot copy content of this page.