Filters
Year Range
20212025
2021
2022
2024
2025
Difficulty
Session
Variant
Sub-topic
138 questions
Computer Science/Paper 2/Data Types and Structures
CAIEAS Level9618-as · Paper 2

Data Types and Structures

138 questions· page 1 of 14

Q52025 May/Jun·P217MMedium

Stacks and queues are both abstract data types.

A stack uses a top-of-stack pointer to indicate the location of the last item added to the stack.

A queue uses two pointers:

  • a front pointer to indicate the location of the next item to be removed from the queue
  • a rear pointer to indicate the location of the next item to be added to the queue.

A queue can be used to reverse the items stored on a stack.

For example, if a stack contains six items:

Initial state of the stack:

Final state of the stack when the items have been reversed:

Describe how the queue could be used to reverse the items that are currently stored on the stack.

Your description must include how the pointers are used in both the stack and queue.

Assume:

  • The stack initially contains an unknown number of items.
  • The queue can store all the items currently stored on the stack.
  • The queue is initially empty.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Similar questions
Q42025 May/Jun·P226MMedium

An algorithm will:

• input 100 integer values, one value at a time
• store the first value input into the first location of the array Number
• store the next input value in the next unused location of the array Number
• output the contents of Number array in the opposite sequence to that in which the values were input.

Complete the program flowchart to represent the algorithm.

Variable declarations are not required.

Similar questions
Q62025 May/Jun·P223 partsMedium
(a)(i)

Complete the trace table below by dry running the procedure Place() when it is called by the statement:

CALL Place(1043, 2, 8)

ValueStartUnusedNewLastCurrent
(a)(ii)

Complete the diagram showing the contents of the global arrays Data and Pointer after the procedure Place() has run to completion when called as shown in part (a)(i).

DataPointer
110181
210072
310103
410564
510925
610626
710347
88
99
1010
(b)

The operation carried out by procedure Place() together with the arrays form part of the implementation of an Abstract Data Type (ADT).

Identify the ADT and state the operation carried out by procedure Place()

Similar questions
Q72025 May/Jun·P224 partsMedium-Hard
(a)

Write efficient pseudocode for module FindCustomer()

(b)

A customer can claim a free coffee for every 11 loyalty points.

The programmer has defined a second program module:

ModuleDescription
PointsReport()• output the customer ID for each customer who has 11 or more loyalty points
• output the average loyalty points for all customers in the Loyalty array along with an appropriate message

Write efficient pseudocode for module PointsReport()

Assume the array contains the data for at least one customer.

(c)(i)

Explain why the 2D array Loyalty can no longer be used.

(c)(ii)

Explain how a 1D array could be used to store both the loyalty points and the amended customer ID.

Similar questions
Q22025 May/Jun·P235 partsMedium-Easy
(a)(i)

Complete the answer column in the following table:

Answer
the memory location of the value that has been on the stack for the longest time
the number of consecutive push operations that will result in the TopOfStack variable containing 409
(a)(ii)

The diagram shows the current state of the stack.

The following sequence of operations are performed:

PUSH 'T'
POP
POP
PUSH 'Z'
PUSH 'X'
POP
PUSH 'Y'

Complete the following diagram to show the state of the stack after the operations have been performed.

(b)(i)

The array is represented in the diagram.

A pointer value of -1 indicates the end of the linked list.

Complete the pointer field to produce a linked list that is in alphabetical order.

IndexDataPointer
0"Neptune"
1"Jupiter"
2"Saturn"
3"Earth"
4"Mercury"
5"Uranus"
(b)(ii)

The variable StartPointer contains the index of the first item in the linked list.

State the value of the variable StartPointer

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

(c)

A third program is also being created to manage a queue.

Describe two features of a queue.

Feature one ..............................................................................................................................

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

Feature two ...............................................................................................................................

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

Similar questions
Q22025 Oct/Nov·P215MMedium

Data is a global 1D array containing 30 elements of type STRING

An algorithm will output:

  • all non-blank elements (elements that do not contain an empty string)
  • the final total of the number of elements output.

Complete the program flowchart to represent the algorithm:

Similar questions
Q32025 Oct/Nov·P213 partsMedium-Easy
(a)(i)

Write pseudocode to declare the record structure for type RentalRecord

(a)(ii)

A 1D array Rental containing 500 elements is used to store the data for all rental records.

Write pseudocode to declare the Rental array.

(b)

State three benefits of using an array of records to store the data for all rentals.

Similar questions
Q42025 Oct/Nov·P213 partsMedium
(a)

Complete the pseudocode for Store()

All variables used in the algorithm must be declared.

PROCEDURE Store()
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDPROCEDURE
(b)(i)

Give two benefits of using a text file instead of an array.

(b)(ii)

State any change that will need to be made before each value is written to the file.

Similar questions
Q82025 Oct/Nov·P213 partsMedium
(a)

Write efficient pseudocode for the module OKToBorrow()

(b)

A second module is defined:

ModuleDescription
ReturnBook()• called with two parameters of type STRING representing a StudentID and a BookID
• searches the array for the relevant loan record
• when found, sets OnLoan to FALSE and returns TRUE
• if a loan record is not found, or the book has already been returned, then returns FALSE

Write efficient pseudocode for the module ReturnBook()

Assume that each student is only allowed to borrow each book only once. That means that there will be no more than one loan record for a given combination of student and book.

(c)

It is decided to introduce a system of fines for books that have been borrowed for too long.

Two new requirements are defined:

  1. Each loan has a maximum length, represented as a number of days.
  2. Each book in the library will be assigned one of three categories. Each category has a different maximum loan length.

Record structure and program design changes are needed to meet these two requirements.

Outline the changes that are necessary to meet the two requirements.

Similar questions
Q22025 Oct/Nov·P225MMedium

Data is a global 1D array containing 20 elements of type REAL

An algorithm will:

  • input a sequence of real values, one at a time
  • assign each value to consecutive array elements, starting from index 1
  • end when the value 99.9 is input, or all 20 elements have been assigned (the value 99.9 must not be stored in the array).

Complete the program flowchart to represent the algorithm:

Similar questions