Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

binary tree

void preorder(node *n) {
    cout << n->value;
    if(n->left!=NULL)
        preorder(n->left);
    if (n->right != NULL)
        preorder(n->right);
}
void inorder(node *n) {
    if (n->left != NULL)
        inorder(n->left);
    cout << n->value;
    if (n->right != NULL)
        inorder(n->right);
}
void postorder(node *n) {
    if (n->left != NULL)
        postorder(n->left);
    if (n->right != NULL)
        postorder(n->right);
    cout << n->value;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #binary #tree
ADD COMMENT
Topic
Name
7+7 =