A cinema stores seat booking data in a 2D array. Each element contains TRUE (booked) or FALSE (available). DECLARE Seats : ARRAY[1:4, 1:6] OF BOOLEAN The cu...

Assessment: Computer Science 0478 | Paper 2 Mock 01 | Algorithms, Programming and Logic Subject: Computer Science - 0478

Question 1 Report

A cinema stores seat booking data in a 2D array. Each element contains TRUE (booked) or FALSE (available).

DECLARE Seats : ARRAY[1:4, 1:6] OF BOOLEAN

The current bookings are shown below (T = booked, F = available):

Seat 1Seat 2Seat 3Seat 4Seat 5Seat 6
Row 1TTFFTT
Row 2FTTTFF
Row 3TTTTTT
Row 4FFTFFT

(a) State the value of Seats[2, 4]. [1]

(b) Write pseudocode to count and output the total number of available (FALSE) seats. [3]

(c) Write pseudocode to count and output the number of available seats in each row. [2]

Answer Details

(a) Seats[2, 4] = TRUE [1] (Row 2, Seat 4 is booked).

(b) Pseudocode to count total available seats: [3]

DECLARE Available : INTEGER
Available <- 0
FOR Row <- 1 TO 4
    FOR Seat <- 1 TO 6
        IF Seats[Row, Seat] = FALSE
            THEN
                Available <- Available + 1
        ENDIF
    NEXT Seat
NEXT Row
OUTPUT "Total available seats: ", Available

[1] for nested loops covering all rows and seats, [1] for checking for FALSE (available), [1] for counting and output.

Counting available (F) seats per row: Row 1 has 2 (seats 3, 4), Row 2 has 3 (seats 1, 5, 6), Row 3 has 0 (fully booked), Row 4 has 4 (seats 1, 2, 4, 5). Total: 2 + 3 + 0 + 4 = 9 available seats.

(c) Pseudocode to count available seats per row: [2]

FOR Row <- 1 TO 4
    DECLARE RowCount : INTEGER
    RowCount <- 0
    FOR Seat <- 1 TO 6
        IF Seats[Row, Seat] = FALSE
            THEN
                RowCount <- RowCount + 1
        ENDIF
    NEXT Seat
    OUTPUT "Row ", Row, " available: ", RowCount
NEXT Row

The key difference from part (b) is that RowCount is reset to 0 at the start of each row, so each row gets its own count. The OUTPUT is inside the outer loop (but after the inner loop), producing one line per row. Expected output: Row 1: 2, Row 2: 3, Row 3: 0, Row 4: 4.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning