Explore BrainMass
Share

Explore BrainMass

    Binary tree: preorder, postorder and inorder scan

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    (a). Draw the binary tree that the following allocations create.

    tnode< int > *root, *a, *c,*d, *e;

    e = new tnode< int > (50);
    d = new tnode< int > (20, NULL, e);
    c = new tnode< int > (30);
    b = new tnode< int > (45, c, NULL);
    a = new tnode< int > (15, b, d);
    root = new tnode< int > (10, NULL, a);

    (b). List the nodes in the order of their visit for an NLR (preorder) scan.
    (c). List the nodes in the order of their visit for an RLN (postorder) scan.
    (d). List the nodes in the order of their visit for an LNR (inorder) scan.

    © BrainMass Inc. brainmass.com October 9, 2019, 11:50 pm ad1c9bdddf
    https://brainmass.com/computer-science/trees/binary-tree-pre-order-post-order-order-scan-269389

    Solution Preview

    a. Assuming that tnode call takes arguments like "tnode(value, left subtree, right subtree), given sequence will result in following tree.

    ...

    Solution Summary

    Binary tree is drawn in ASCII mode, and is available in the text response to the question.

    $2.19