Past-paper question · 2015 October-November · Paper 33 · Q7(d)(ii)

Question 7(d)(ii) 2015 · October-November · Paper 33 · 22 marks

Original past-paper question for 7(D)(II)
Original past-paper question for 7(D)(II)
Original past-paper question for 7(D)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 7(D)(II)

Official answer for Question 7

Part (d)

(ii)

(ii)

✓
USER21
✓
RUNNING
✓
READY
✓
RED
✓
RUN
✓
RED
✓
USER34
✓
READY
✓
RUNNING
✓
RED
✓
RUN
✓
RED
✓
USER46
✓
READY
✓
READY
✓
RUN
✓
SUSP
✓
RED
✓
RUN
✓
0

Question 50

✓
100
✓
150
✓
200
✓
250
✓
300
✓
350
✓
400
✓
450
✓
500
✓
550
✓
1 mark each
[5]

Mark scheme 9691_w15_ms_33.pdf →

Show text version of question

Question 7

Part (d)

(ii)

Question 7

. . . .

2000

[4]

Question 12

Part (c)

An algorithm is designed in pseudocode to search the binary tree for a particular city.

The algorithm uses the additional variables below:

Variable Data type Description SearchCity STRING City to search for Current INTEGER The array subscript for the item currently considered IsFound BOOLEAN Flags to TRUE when SearchCity is found

Complete the algorithm below:

// binary tree search

INPUT ................................................................................................................................ IsFound ← FALSE Current ← RootPtr REPEAT IF City[Current] = ............................................................................................. THEN // found OUTPUT "Found"

........................................................................................................................ ELSE IF SearchCity > City[Current] THEN // move right

........................................................................................................... ELSE Current ← LeftPtr[Current] ENDIF ENDIF UNTIL Current = 0 OR ...............................................................................................

IF ..................................................................................................................................... THEN OUTPUT SearchCity "Not Found" ENDIF

[6]

Question 13

6 A high-level programming language has a built-in function SumRange defined as follows:

SumRange(ThisInteger1 : INTEGER, ThisInteger2 : INTEGER [Flag : CHAR]) RETURNS INTEGER returns the integer value calculated as the sum of all integers between ThisInteger1 and ThisInteger2.

The square brackets denote that Flag is optional. It takes values as follows:

  • 'Y' – denotes both boundary values are to be included
  • 'N' – denotes both boundary values will not be included

If Flag is omitted, both boundary values are included.

For example: SumRange(3, 6, 'Y') returns 18 SumRange(3, 6, 'N') returns 9

An error is generated if:

  • The function is not properly formed, or
  • ThisInteger2 is less than ThisInteger1

(i)

State the function name and parameters for the above function.

Function name ..........................................................................................................................

Parameters ...............................................................................................................................

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

What value is returned from the following function calls?

(ii)

SumRange(1, 3)

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

(iii)

SumRange("31", "33", 'Y')

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

(iv)

SumRange(1.5, 4.5)

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

(v)

SumRange(4, 7, 'N')

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

(vi)

SumRange(7, 4, 'N')

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

Question 14

7 The diagram shows the main memory contents of a computer system. It is controlled by a multi- programming operating system.

Operating System A B

Partition 1 PROG2

PROG7 PROG16

Unused

Partition 2 USER21 USER34 USER46 Unused Partition 2 of the main memory is used for interactive programs. The low-level scheduler operates a round-robin strategy. It allocates a time slice of 100 milliseconds.

(ii)

The program USER21 starts its time slice at time zero. The scheduler puts programs

that are ready into the RUNNING state in the same order as the rows in the following diagram.

USER21 RUNNING READY USER34 READY RUNNING USER46 READY

0 50 100 150 200 250 300 350 400 450 500 550

  • During its first time slice, USER46 becomes suspended after 50 ms.
  • USER46 is changed to the ready state 100 ms after its suspension.

Label the diagram to show how the state of each program changes for the first 500 ms. You should use the labels RUNNING, READY and SUSPENDED. When necessary, you may abbreviate any of these to its first three letters.

[5]
Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

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

Keep practising this topic