User interface language: English | Español

Date November 2019 Marks available 6 Reference code 19N.1.HL.TZ0.12
Level HL Paper 1 Time zone no time zone
Command term Explain Question number 12 Adapted from N/A

Question

Consider the following binary tree.

An inorder traversal of this binary tree will produce a list of names sorted in ascending order.

State two applications of stacks.

[2]
a.

Explain the use of a one-dimensional array as a static stack. Your answer should include brief outlines of the push and pop operations and the tests for empty and full stacks. 

[6]
b.

State the result of postorder traversal.

[1]
c.i.

Draw the binary tree after deleting the root node.

[3]
c.ii.

Compare the use of static and dynamic data structures.

[3]
d.

Markscheme

Award [2 max]
Holding all data of a function/method call; simulation of recursion;
Conversion of expressions (infix to postfix, infix to prefix, etc.)
Evaluating expression;
Parsing;

a.

Award [6 max]
Award [3 max] for the following:
An array A of N elements should be initialized (fixed, predetermined size);

keep track of the top of the stack since not all of the array holds stack elements (in an integer variable, for example, named TOP);

the main property of a stack is that stack values/objects go on and come off of the one end of the stack (LIFO data structure);

Award [1] for each stack method outlined.

Push
Places a value (object) on the top of the stack;
Increase TOP by one and set A[TOP]= value;

Pop
Returns a value from the top of the stack and removes that value from the top of the stack;
Returns A[TOP] and decreases TOP by 1;

IsEmpty
Reports whether the stack is empty or not / returns True if the stack is empty, False otherwise;
Returns True if TOP is less than 0, False otherwise;

IsFull
Reports whether the stack is full or not/ returns True is stack is full, False otherwise;
Returns True if TOP is greater than N-1 (where N is size of the array), False otherwise;

b.

Award [1 max]  
The names must be in the following order:
Elm, Elder, Holly, Rowan, Larch, Hazel;

c.i.

Award [3 max]  
Award [1] for the correct root.
Award [1] for the correct left subtree.
Award [1] for the correct right subtree.

c.ii.

Award [3 max]
Static data structures are fixed sized (for example, arrays) whilst dynamic data structure (for example, trees, linked lists) have flexible size;

The size of static data structures is predetermined; the amount of memory once allocated to them at compile time cannot change on run time whereas dynamic data structures they can grow or shrink as needed to contain the data to be stored;

Slower access to elements of dynamic data structure (sequential access) when compared with (direct) access to elements of static data structures;

d.

Examiners report

Mostly well answered questions.

a.

Not all candidates answered this question, but most of those who did outlined the push and pop operations and the tests for empty and full stacks. The use of a one-dimensional array as a static stack was weakly explained.

b.

Mostly well answered.

c.i.

Mostly well answered.

c.ii.

Mostly well answered.

d.

Syllabus sections

Topic 5: Abstract data structures » 5.1 Abstract data structures
Show 80 related questions
Topic 5: Abstract data structures

View options