Six original Cambridge-style questions on 1D and 2D arrays, with a trace table and pseudocode mark points.
DECLARE X : ARRAY[1:n] OF type or ARRAY[1:r, 1:c] OF type.An array is declared as DECLARE Temps : ARRAY[0:23] OF REAL. State (a) the lower bound, (b) the upper bound, (c) the number of elements.
Write pseudocode to declare a 1D array Names to hold 50 names, and to set every element to the empty string.
DECLARE Names : ARRAY[1:50] OF STRING. ✓FOR Index ← 1 TO 50 ... NEXT Index. ✓Names[Index] ← "" inside the loop. ✓Nums holds 3, 8, 2, 8, 5, 1 in elements 1 to 6. Complete a trace table for this pseudocode, state the output and describe what it does.
Count ← 0
Last ← Nums[1]
FOR i ← 2 TO 6
IF Nums[i] > Last THEN
Count ← Count + 1
ENDIF
Last ← Nums[i]
NEXT i
OUTPUT CountSales : ARRAY[1:4, 1:12] OF REAL holds the sales of 4 shops (rows) for 12 months (columns). Write pseudocode to output the total sales for each month, and then the number of the month with the highest total.
BestTotal ← -1 (or the total of month 1) and BestMonth ← 1. ✓FOR Month ← 1 TO 12; set MonthTotal ← 0 inside it. ✓FOR Shop ← 1 TO 4 with MonthTotal ← MonthTotal + Sales[Shop, Month]. ✓OUTPUT Month, MonthTotal. ✓IF MonthTotal > BestTotal THEN BestTotal ← MonthTotal, BestMonth ← Month. ✓OUTPUT BestMonth. ✓A theatre has 12 rows of 25 seats. The program records whether each seat is booked. (a) Choose a suitable data structure, justify your choice and write its declaration. (b) Write a statement to record that seat 17 in row 5 is booked.
DECLARE Seats : ARRAY[1:12, 1:25] OF BOOLEAN. ✓Seats[5, 17] ← TRUE. ✓This pseudocode should output the total of all 48 values in Sales, but the output is wrong. Identify the error, explain its effect and write the correction.
FOR Shop ← 1 TO 4
Total ← 0
FOR Month ← 1 TO 12
Total ← Total + Sales[Shop, Month]
NEXT Month
NEXT Shop
OUTPUT TotalTotal ← 0 is inside the outer loop. ✓Total ← 0 to before FOR Shop ← 1 TO 4. ✓Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.