Sunday, March 5, 2017

CLRS Exercise 12.1-4

12.1-4
Give recursive algorithms that perform preorder and postorder tree walks in $\Theta(n)$ time on a tree of $n$ nodes.

Preorder traversal:
PREORDER-TREE-WALK(x)
        if (x != NIL)
                print x.key
                PREORDER-TREE-WALK(x.left)
                PREORDER-TREE-WALK(x.right)
Postorder traversal:
POSTORDER-TREE-WALK(x)
        if (x != NIL)
                PREORDER-TREE-WALK(x.left)
                PREORDER-TREE-WALK(x.right)
                print x.key

1 comment:

nahirkahane said...

Grosvenor Grand Opening on November 15 - Mapyro
The 부천 출장마사지 casino is 여수 출장샵 owned and operated by Betsson, a 동두천 출장마사지 division of 화성 출장마사지 Grosvenor in London. It 사천 출장마사지 was opened in November 1985 and has since grown into a