← Back to problems
UNSW COMP2521 · hard

21T3 Q8 — Sum of odd values (rebuild tree)

stdin: N, then the preorder (N ints), then the inorder (N ints) of a binary tree with distinct values. Rebuild the tree and print the sum of all odd node values.


Single-file C (gcc -O0 -Wall). Self-contained reframing of the exam's ADT-completion question. From COMP2521 21T3 Sample.