EXAM QUESTIONS · AS LEVEL 9618

Data Types and Structures Exam-Style Questions with Answers (A Level 9618)

Original exam-style questions on data types, records, 1D and 2D arrays, text files, and the abstract data types stack, queue and linked list for Cambridge AS & A Level Computer Science 9618 (Paper 2). There are 20 marks in total. Try each question on paper first, then press Show answer to see the mark scheme. Answers that can be calculated mark themselves.

Question 1[3 marks]

State the most suitable data type for each value.

  1. A single letter grade, e.g. “B” [1]
  2. The date a library book is due back [1]
  3. The cost of an item in dollars and cents [1]
Show answer
  1. CHAR [1]
  2. DATE [1]
  3. REAL [1]
Question 2[3 marks]

Write pseudocode to declare a 2D array Seats with 10 rows and 20 columns of Boolean values, and set every element to FALSE.

Show answer
DECLARE Seats : ARRAY[1:10, 1:20] OF BOOLEAN
FOR Row ← 1 TO 10
   FOR Col ← 1 TO 20
      Seats[Row, Col] ← FALSE
   NEXT Col
NEXT Row
  • 1 mark: correct declaration with bounds and data type
  • 1 mark: nested loops with correct ranges
  • 1 mark: each element set to FALSE
Question 3[2 marks]

A stack is empty. These operations are carried out in order:

PUSH A, PUSH B, POP, PUSH C, PUSH D, POP

State the contents of the stack from bottom to top.

Show answer

A, C (C is at the top) [2]

After PUSH A, PUSH B the stack is A, B. POP removes B. PUSH C, PUSH D gives A, C, D. POP removes D.

Question 4[2 marks]

A queue contains P, Q, R, S (P at the front). Two items are removed and then T is added. State the contents of the queue from front to rear.

Show answer

R, S, T [2]

A queue is FIFO, so P then Q are removed, and T joins at the rear.

Question 5[3 marks]

A linked list is stored in arrays. The start pointer is 1. A pointer of 0 means the end of the list.

IndexNamePointer
1Mia4
2Ali3
3Kai0
4Noor2

State the names in the order they are visited when the list is traversed.

Show answer

Mia, Noor, Ali, Kai [3]

Start at 1 (Mia) → pointer 4 (Noor) → pointer 2 (Ali) → pointer 3 (Kai) → pointer 0, end. 1 mark for starting at Mia, 1 mark for following the pointers, 1 mark for the complete correct order.

Question 6[3 marks]

Explain why a linked list can be a better choice than an array for storing a list that changes often.

Show answer

Any three from:

  • Items can be inserted or deleted by changing pointers only.
  • Other items do not have to be moved/shuffled, which saves time.
  • A dynamic linked list can grow and shrink as needed, so memory is not wasted.
  • An array has a fixed size that must be decided in advance.
Question 7[4 marks]

Describe the steps needed to push an item onto a stack implemented using an array and a top-of-stack pointer.

Show answer

Any four from:

  • Check whether the stack is full (top pointer = maximum size).
  • If it is full, report an error (stack overflow) and stop.
  • Otherwise, increment the top-of-stack pointer.
  • Store the new item in the array at the position given by the top pointer.

Frequently asked questions

What is the difference between a stack and a queue?

A stack is LIFO: the last item added is the first removed. A queue is FIFO: the first item added is the first removed.

Are these past paper questions?

No. These are original exam-style questions written by a Computer Science teacher in the Cambridge style.

Revise the topic: 9618 data types and structures notes · 9618 flashcards · All exam-style questions