Posts

How To Create B-Tree Of Order M by Using Reactive Method

 ///Order Must Be Odd #include<iostream> #include<vector> #include<algorithm> using namespace std; struct Node {     int order;///contains order     vector<int> key;///to store keys     vector<Node*> child;///to store child     bool isLeaf;///flag to indicate whether the node is leaf node or not.if the node is leaf then no key in that node will have child     ///but if node is not leaf then all the keys will have left and right child     Node(int order)     {         this->order=order;         isLeaf=false;     }     bool isFull()///to check node is full or not     {         return(key.size()==(order-1));     } }; int divide(Node *root,Node *extra,int *mid_index)///function to divide root by mid value and returns mid value,stores half values in root and half inside extra node { ...

How To Create Right Threaded Binary Search Tree(Recursive)?

Image
  #include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; struct node {     int data;     node *left,*right;     bool rightThread;     node(int data)     {         this->data=data;         left=right=NULL;         rightThread=false;     } }; node* insert_data(node *root,int data) {     if(root==NULL)     {         root=new node(data);     }     else if(data<=root->data)     {         root->left=insert_data(root->left,data);         if(root->left->right==NULL)         {             root->left->right=root;             root->left->rightThread=true;         }     }     el...