Wednesday, December 14, 2011

Print Binary Tree Questions

Print Left View a Binary Tree
http://www.geeksforgeeks.org/print-left-view-binary-tree/

Print Edge Nodes[Boundary] of a Binary Tree
http://articles.leetcode.com/print-edge-nodes-boundary-of-binary
http://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/

Print leftmost and rightmost nodes of a Binary Tree
http://www.leetcode.com/2010/10/print-edge-nodes-boundary-of-binary.html
http://www.geeksforgeeks.org/archives/23796

Diagonal Traversal of Binary Tree
http://www.geeksforgeeks.org/diagonal-traversal-of-binary-tree/

Print a Binary tree in vertical Order
http://www.geeksforgeeks.org/print-binary-tree-vertical-order/
http://www.geeksforgeeks.org/print-binary-tree-vertical-order-set-2/

Print Right View of a Binary Tree
http://www.geeksforgeeks.org/print-right-view-binary-tree-2/

Given a binary tree, print out all of its root-to-leaf paths one per line.
http://www.geeksforgeeks.org/given-a-binary-tree-print-out-all-of-its-root-to-leaf-paths-one-per-line/

Print Ancestors of a given node in Binary Tree
http://www.geeksforgeeks.org/print-ancestors-of-a-given-node-in-binary-tree/

Print nodes at k distance from root
http://www.geeksforgeeks.org/print-nodes-at-k-distance-from-root/

Print all nodes that are at distance k from a leaf node
http://www.geeksforgeeks.org/print-nodes-distance-k-leaf-node/

Print all nodes that don’t have sibling
http://www.geeksforgeeks.org/print-nodes-dont-sibling-binary-tree/

Print Bottom View of a Binary Tree
http://www.geeksforgeeks.org/bottom-view-binary-tree/

Print Nodes in Top View of Binary Tree
http://www.geeksforgeeks.org/print-nodes-top-view-binary-tree/

Print nodes between two given level numbers of a binary tree
http://www.geeksforgeeks.org/given-binary-tree-print-nodes-two-given-level-numbers/

Print leftmost and rightmost nodes of a Binary Tree
http://www.geeksforgeeks.org/print-leftmost-and-rightmost-nodes-of-a-binary-tree/

Print extreme nodes of each level of Binary Tree in alternate order
http://www.geeksforgeeks.org/print-extreme-nodes-of-each-level-of-binary-tree-in-alternate-order/

1 comment:

  1. void print(int arr[],int len)
    { int i;
    for (i=0;i < len;i++)
    printf("%d ",arr[i]);
    }

    void printPaths(struct node *head, int path[],int pathLength)
    {
    if (head==NULL)
    return;
    else
    {
    path[pathLength]=head->data;
    pathLength++;}

    if ((head->left == NULL && head->right == NULL))
    { printf("\n");
    print(path,pathLength);
    }
    else{
    printPaths(head->left,path,pathLength);
    printPaths( head->right,path,pathLength);}
    }

    ReplyDelete