Question bank › A-level Computer Science › Fundamentals of algorithms

Tree traversal and reverse Polish notation

Answer on paper first, then reveal the mark scheme one mark at a time.

1Standard5 marks

The binary tree below stores integers.

(a) Write the order in which the nodes are visited in a pre-order traversal. [1]

(b) Write the order in which the nodes are visited in an in-order traversal. [1]

(c) Write the order in which the nodes are visited in a post-order traversal. [1]

(d) The tree is a binary search tree. Explain how your answer to part (b) shows this. [2]

40256015325075
2Standard4 marks

(a) Convert the infix expression (3 + 4) * (8 - 2) to reverse Polish notation (RPN). [2]

(b) Evaluate the RPN expression 5 1 2 + 4 * + 3 -. Show the contents of the stack as you work. [2]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session