Posts

Showing posts from April, 2022

BST Assignment 2:

  BINARY SEARCH TREE: 1.Implement binary search tree (BST) to perform a following operation:    i) BST - copy and  mirror image of BST,                  Counting leaf node , non leaf node , total nodes //assignment 2: #include < stdio.h > #include < stdlib.h >   typedef struct node   {     int data ;     struct node * left , * right ;   } BST ;  BST * create ();  BST * insert ( BST * , int );  BST * preorder ( BST * );   int totalnodes ( BST * );   int leafnodes ( BST * );   int nonleafnodes ( BST * );  BST * mirrorimage ( BST * );   static int count = 0 ;   int main ()   {       int ch , x , m ;           BST * root = NULL , * ans , * mirror ;     do     {       printf ( "\n 1:create \n 2:insert \n 3:preorder " );       print...

BST Assignment 1:

BINARY SEARCH TREE: 1.Implement binary search tree (BST) to perform a following operation:    i) BST - create,recursive traversal-Inorder,preorder,postorder    ii)insert and delete #include < stdio.h > #include < stdlib.h >   typedef struct node   {     int data ;     struct node * left , * right ;   } BST ;  BST * create ();  BST * insert ( BST * , int );  BST * inorder ( BST * );  BST * preorder ( BST * );  BST * postorder ( BST * );  BST * delete ( BST * , int );     static int count = 0 ;   int main ()   {       int ch , x , m ;           BST * root = NULL , * ans ;     do     {       printf ( "\n 1:create \n 2:insert \n 3:inorder \n 4:preorder \n 5:postorder " );       printf ( "\n 6:delete " );       printf ( "\n\n enter your choice: " );     ...

Graph

GRAPH: indegree and outdegree of the vertices: #include < stdio.h >   int main ()   {     int a [ 10 ][ 10 ], n , j , i , out = 0 , in = 0 ;     printf ( " Enter the How many vertex: " );     scanf ( " %d " , & n );     for ( i = 0 ; i < n ; i ++ )       {       for ( j = 0 ; j < n ; j ++ )         {           a [ i ][ j ] = 0 ;             if ( i != j )               {                 printf ( " Is there Edge between %d and %d (1/0): " , i + 1 , j + 1 );                 scanf ( " %d " , & a [ i ][ j ]);               }         }       }     printf ( " vertex indegree outdegree \n" );     for ( i = 0 ; i < ...