Example #1
0
void printlevelorder(struct BT *root,int level)
    {
        if(!root)
            return;
        if(level==0)
            printf("[%d]\t",root->data);
         else
            printlevelorder(root->l,level-1);
            printlevelorder(root->r,level-1);   
                
    }    
Example #2
0
main()
    {
    
    
        struct BT *rt=NULL;
        rt=nn(95);
        rt->l=nn(90);
        rt->r=nn(99);
        rt->l->l=nn(91);
        rt->l->r=nn(92);
        rt->r->l=nn(98);
        rt->r->r=nn(97);
        rt->r->l->l=nn(96);
        rt->r->r->l=nn(100);
        rt->l->r->l=nn(1);
       
       
       
       int i;
       
        for(i=0;i<10;i++)
            {
                printlevelorder(rt,i);
                printf("\n");
            }    
            
      // printlevel(rt);
      int path[1000]; 
    printpath(rt,path,0);
    }
Example #3
0
void main()
{
    struct node* node = buildTree(12);
    printlevelorder(node);
    printf("\n Is BST = %s\n", isBST(node, 500, -500) ? "Yes" : "No");
}