Past-paper question · 2015 May-June · Paper 31 · Q5(c)(iv)

Question 5(c)(iv) 2015 · May-June · Paper 31 · 35 marks

Original past-paper question for 5(C)(IV)
Original past-paper question for 5(C)(IV)
Original past-paper question for 5(C)(IV)
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_31.pdf →

Show text version of question

Question 5

Part (c)

(iv)

Question 5

<packet> ::= <start><string><stop>

Circle whether or not each of the following sequence of characters is a valid packet.

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

(iv)

The rules need to change as follows.

A
string with a sequence of one or more hash (#) characters is to be allowed as a valid

string:

0#1 and 0####1 would both be a valid packet.

Implement this by:

  • making no change to rule 1
  • making the appropriate changes (if any) to rules 2, 3, 4 and 5
  • adding one or more new rule(s)

Show the complete set of rules below.

Rule number

1 <char> ::= A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z

2 <string> ::= ..................................................................................................................

3 <start> ::= ..................................................................................................................

4 <stop> ::= ..................................................................................................................

5 <packet> ::= ..................................................................................................................

6 ..............................................................................................................................................

7 ..............................................................................................................................................

[3]

Question 9

Question 3

Part (a)

The following terms are used in object-oriented programming (OOP) and design.

Draw a line connecting each term to the appropriate definition.

In the bottom box, state the term which matches the unused definition.

Term Definition

Encapsulation An object created from a class.

The ability of a subclass to use properties Inheritance and methods of a parent class.

A
data value which is assigned and stored

Class for an object.

The definition of an object. The ‘blueprint’ Instance from which objects are created.

An action of an object. Implemented with Method procedures and functions.

Restricts the programmer’s access to the object’s data. Data values can only be ................................. read or written using methods provided by the class.

[6]

Question 10

Part (b)

A company’s website is maintained by several employees. The company has a number of

permanent employees whose job title is either ‘programmer’ or ‘web designer’.

An agency supplies the company with contract employees when there is a need for specialist skills. Contract employees have the job title ‘graphic designer’ or ‘technical author’.

Employees have recorded:

  • employee reference number
  • date first worked for company

Contract employees have recorded:

  • agency they were supplied by
  • agreed hourly rate of pay
  • job role

Permanent employees have recorded:

  • salary grade
  • courses attended

Programmers have recorded:

  • programming languages used

Web designers have recorded:

  • mark-up languages used

This scenario is to be implemented using object-oriented programming.

Question 11

Complete the class diagram using the classes:

Employee, Contract, Permanent, Programmer, WebDesigner.

Show properties only for the given data.

Employee EmployeeRefNumber: STRING

[8]

Question 12

Question 4

Part (a)

Briefly describe the operation of a stack data structure.

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

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

High level language programs make extensive use of subroutines.

A
stack is used to store data about each subroutine call.

The data are the return address, the register contents and the values of all local variables.

A
student project is to simulate the saving and retrieval of the data for subroutine calls.

The student simplifies this for their project and will store on the stack only the return addresses.

Memory address (denary) 100 // Main program 101 <statements> …

172 CALL SUB1 173 … // end main program 200 PROCEDURE SUB1 201 <statements> …

268 CALL SUB2 269 <statements> …

280 CALL SUB3 281 <statements>

320 END PROCEDURE 321 PROCEDURE SUB2 322 <statements> … 399 END PROCEDURE 400 PROCEDURE SUB3 401 <statements> …

562 END PROCEDURE

Question 13

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

Identifier Data type Description

Stack ARRAY[1 : 100] OF INTEGER Stores the return address for each procedure call Stores the index position of the TOS INTEGER return address currently at the top of the stack

NewAddress INTEGER Stores the new return address to be added to Stack

Part (b)

The diagram shows the stack after the first procedure call at line 172.

Stack 100

Question 99

Question 5

Question 4

Question 3

Question 2

TOS 1 173

(i)

Complete the diagram to show the contents of the stack and the value of TOS after each

change.

[5]

(ii)

The student uses the procedure PushAddress to simulate adding a return address to

the stack.

The incomplete pseudocode for the procedure PushAddress is shown below.

Using the given variables, fill in the missing pseudocode.

PROCEDURE PushAddress IF TOS = 100 THEN OUTPUT "............................................................................................................." ELSE INPUT .................................................................................................................... TOS ← .................................................................................................................... ..................................................................................................... ← NewAddress ENDIF ENDPROCEDURE

[4]

Question 14

Part (c)

The student uses the procedure PopAddress to simulate retrieving a return address from

the stack.

Complete the pseudocode for this PopAddress procedure.

PROCEDURE PopAddress IF ......................................................................................................................................... THEN OUTPUT "There are no current procedure calls" ELSE OUTPUT "Address" Stack[TOS] ........................................................................................................................................ ENDIF ENDPROCEDURE

[2]

Question 15

Question 5 begins on page 16.

Question 16

5 A computer system stores integers in a single byte using two’s complement representation.

Part (a)

State the denary integer represented by the following two bytes.

Give the hexadecimal representation of each integer.

(i)

0 1 1 0 1 1 1 1 Denary ........................................................

Hexadecimal ...............................................

[2]

(ii)

1 1 1 0 0 0 1 1 Denary ........................................................

Hexadecimal ...............................................

[2]

Part (b)

State the most negative denary integer that can be represented.

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

Part (c)

Why do computer scientists often write binary numbers in hexadecimal?

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

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

Topic relevance

Why this question appears here

98% assigned-topic match · Further programming › Programming paradigms

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_31.pdf

Keep practising this topic