Past-paper question · 2015 May-June · Paper 33 · Q5(c)(iii)

Question 5(c)(iii) 2015 · May-June · Paper 33 · 23 marks

Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Original past-paper question for 5(C)(III)
Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9691_s15_ms_33.pdf →

Show text version of question

Question 5

Part (c)

(iii)

Question 5

<productcode> ::= <producttype><digitstring><location>

(i)

A BNF rule may be recursive.

What is meant by a recursive rule?

...........................................................................................................................................

.......................................................................................................................................[1]

(ii)

For each statement below, state whether it is TRUE or FALSE.

Statement TRUE or FALSE None of the given rules are recursive Rule 4 is recursive Rule 5 is recursive

[1]

Question 7

Part (c)

Circle whether or not each of the following sequences of characters is a valid product code.

Show how you arrived at your answer by listing, in order, the rules used.

(i)

D175N Valid / Invalid (circle)

Rules .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii)

W058M Valid / Invalid (circle)

Rules .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii)

C86N Valid / Invalid (circle)

Rules .................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

Question 8

Part of the pseudocode for the object-oriented programming is shown below.

CLASS Project

PRIVATE ProjectID : STRING

<statements>

PROCEDURE set_ProjectID()

<statements>

ENDPROCEDURE

PROCEDURE get_ProjectID()

<statements>

ENDPROCEDURE

ENDCLASS

CLASS Network INHERITS Project

<statements>

ENDCLASS

// Main program …

DECLARE ThisNetworkProject : Network

<statements>

Question 11

Explain the following terms, with reference to the given pseudocode.

(iii)

Encapsulation

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

Question 12

Question 4

Part (a)

Describe the operation of a stack data structure.

...................................................................................................................................................

...............................................................................................................................................[1]

A
stack data structure is used to control the adding and removal of animal names.

The stack is implemented using the following data structure and variables.

Identifier Data type Description Animal ARRAY[0 : 99] OF STRING Stores the animal names. Index pointer for the Animal Index INTEGER array Array index position of the item StackPointer INTEGER at the top of the stack. Value –1 indicates the stack is empty. Name of the new animal to be NewAnimal STRING added to the Animal array.

Part (b)

Complete the pseudocode procedure below to initialise the stack.

StackPointer -1 Animal 0 ”” 1 ”” 2 ”” :

: 99 ””

PROCEDURE InitialiseStack

FOR Index 0 to 99

Animal[............................................................................................................] ""

ENDFOR

StackPointer ...............................................................................................................

ENDPROCEDURE

[2]

Question 13

Part (c)

The diagram shows the state of the stack after the following operations:

  • three values were added – BEAR, PANDA and CAMEL (in that order)
  • a value was removed from the stack
  • a new value APE was added

Animal 0 BEAR 1 PANDA StackPointer 2 CAMEL APE 3 ”” 4 ”” 5 ””

99 ””

(i)

State the current value of:

Animal[3] ................................................

StackPointer - 1 ................................................

[2]

(ii)

Adding a value to the stack is done with a procedure Push.

Shown below is the incomplete pseudocode for procedure Push.

Using the variables given, fill in the missing pseudocode.

PROCEDURE Push

IF ...............................................................................................................................

THEN

OUTPUT "REFUSED – stack is full"

ELSE

INPUT ................................................................................................................

StackPointer ............................................................................................

.................................................................................................. NewAnimal

ENDIF

ENDPROCEDURE

[4]

Question 14

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9691_s15_qp_33.pdf

Keep practising this topic