Note AcademyNote Academy

Computer Science · Oct / Nov 2021 · Paper 1 HL · Question 13

Adapt for 2027Working with 1D and 2D arrays is on the syllabus (B2.2.2); write the algorithms in Python or Java instead of IB pseudocode.

IBCS

As printed in the paper

The question as text

13. A bus company provides services within a city. Passengers can look up the distance between any two bus stations on any of its routes. For each route, a one-dimensional string array is used to store the names of all bus stations on the route and a two-dimensional array is used to store the distances between the bus stations (in kilometres). Only the lower triangle of the two-dimensional array is used to store the distances. Figure 1 shows data about Route X, a bus route between Oppox and Dovely. Figure 1: One-dimensional string array, ROUTE_X_NAMES, and two-dimensional array, ROUTE_X_DISTANCES, for Route X ROUTE_X_NAMES ROUTE_X_DISTANCES [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [0] Oppox [0] 0 0 0 0 0 0 0 0 0 0 [1] Thamesley [1] 1.2 0 0 0 0 0 0 0 0 0 [2] Brinkley [2] 2.2 1.0 0 0 0 0 0 0 0 0 [3] Kiko [3] 6.6 3.4 2.2 0 0 0 0 0 0 0 [4] Endsley [4] 5.7 4.5 3.5 1.3 0 0 0 0 0 0 [5] Kingsley [5] 7.1 5.9 4.9 2.7 1.4 0 0 0 0 0 [6] Allapay [6] 8.0 6.8 5.8 3.6 2.3 0.9 0 0 0 0 [7] Kronos [7] 10.1 9.1 6.9 4.7 3.4 2.0 1.1 0 0 0 [8] Longlines [8] 10.5 9.3 8.1 5.9 4.6 3.2 2.3 1.2 0 0 [9] Dovely [9] 11.3 10.1 9.1 6.9 5.6 4.2 3.3 2.1 0.9 0 For example, the distance between Kingsley and Kronos (2.0 kilometres) can be found in ROUTE_X_DISTANCES [7][5]. (This question continues on the following page) (Question 13 continued)

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 13(a)[1]

  • 13(b)[5]

  • 13(c)[6]

  • 13(d)[3]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.