Commonly asked Data Structures and Algorithms Problems by big tech and different solution approaches with code in Java and C

Powered by Blogger.

Tuesday, August 15, 2017

Left View of Tree



Code:

    int count=0;
    void leftview(Node root,int k)
    {
        if(root==null)
        return;
        if(count<k){
        System.out.print(root.data+" ");
            count=k;
        }
        leftview(root.left,k+1);
        leftview(root.right,k+1);
    }

0 Comments:

Post a Comment

Stats