| English | 의미 |
|---|---|
| array/əˈreɪ/ | 배열 |
| element/ˈelɪmənt/ | 원소 |
| index/ˈɪndeks/ | 색인 |
| lower bound/ˈləʊə baʊnd/ | 하한 |
| upper bound/ˈʌpə baʊnd/ | 상한 |
| dimension/daɪˈmenʃn/ | 차원 |
| nested loops/ˈnestɪd luːps/ | 중첩 루프 |
| linear search/ˈlɪnɪə sɜːtʃ/ | 선형 탐색 |
| bubble sort/ˈbʌbl sɔːt/ | 버블 정렬 |
Seat 14C
- A cinema has 300 seats. Its booking system does not have 300 variables called
Seat1A,Seat1B,Seat1C. It has one array 数组, and your ticket is an address into it: row 14, seat C. - One name, hundreds of values, each found by a number. Add a row and the code does not change; loop over the numbers and you have checked every seat.
- Almost every Paper 2 algorithm walks an array: searching it, summing it, sorting it, finding its largest value.
- This lesson is the vocabulary, the declarations, and the four algorithms the examiner asks for in pseudocode and in words.
The vocabulary
- An array is a data structure holding a fixed number of elements 元素 of the same data type under one identifier, each reached by an index 索引.
- The lower bound 下界 and upper bound 上界 are the first and last valid index. The number of elements is upper bound − lower bound + 1.
- The dimension 维度 is how many indices an element needs: one for a list, two for a table.
- In
ThisArray[n] ← 42the array has one dimension, the index is theINTEGERvariablen, and the element at that index receives42.

One identifier, an index for each element, bounds at both ends
배열은 다음을 저장합니다:
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
배열은 인덱스로 접근할 수 있는 동일 타입 항목의 순서 있는 수집체입니다. (레코드는 서로 다른 타입을 묶습니다.)
배열은 하나의 이름 아래에 ______ 타입의 많은 값을 보유하는 데이터 구조입니다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
각 값은 자신의 인덱스를 통해 접근됩니다.
DECLARE Marks : ARRAY[0:99] OF INTEGER는 ____개의 요소를 가진 배열을 선언합니다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
상한경계(lower bound)를 뺀 값에 하한경계(upper bound)를 더한 값: 99 − 0 + 1 = 100. 양쪽 경계 모두 유효한 인덱스입니다.
Worked example: declaring the array a task needs
- A declaration needs the identifier, the bounds and the data type.
- 120 readings that may have a decimal place:
DECLARE Data : ARRAY[1:120] OF REAL - A table of 150 rows and two columns of text:
DECLARE Names : ARRAY[1:150, 1:2] OF STRING - Say the count if asked:
[0:99]holds 100 elements, not 99.
150개의 행과 2개의 열로 이루어진 텍스트 표(table)를 저장하는 선언은 무엇입니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
두 차원, 각각 하한 및 상한 경계를 가지며, 요소의 데이터 타입입니다. 두 번째 옵션은 하나의 긴 목록이며, 세 번째는 타입이 없고, 네 번째는 하한 경계가 없습니다.
Processing a 1-D array
DECLARE Names : ARRAY[1:5] OF STRING
Names[3] ← "Cara"
FOR i ← 1 TO 5
OUTPUT Names[i]
NEXT i
- A
FORloop from the lower bound to the upper bound visits every element once. - For a sum, count, maximum or minimum, set a running variable before the loop and update it inside.
2-D arrays
DECLARE Grid : ARRAY[1:3, 1:4] OF INTEGER
Grid[2, 3] ← 99 // row 2, column 3
- The first index is the row, the second the column. Nested loops 嵌套循环 visit every cell: the outer loop over rows, the inner over columns.
- Use 1-D for a single sequence and 2-D when the data has two natural dimensions, such as a grid of seats or a table of marks by student and subject.

Grid[row, column], always in that order
2차원 배열을 [행, 열]로 인덱싱하십시오
2차원 배열은 격자(grid)입니다. Grid[row, column]는 정확히 하나의 셀에 접근합니다 — 행과 열을 변경하여 어느 값에 도달하는지 확인하십시오.
Grid[2, 3]에서 어떤 셀에 접근합니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
첫 번째 인덱스는 행, 두 번째 인덱스는 열이므로 행 2, 열 3입니다.
Worked example: a linear search that can say "not found"
- A linear search 线性查找 checks each element in turn from the first until the target is found or the end is reached.
FoundAt ← -1
FOR i ← 1 TO n
IF A[i] = Target THEN
FoundAt ← i
ENDIF
NEXT i
IF FoundAt = -1 THEN
OUTPUT "Not found"
ELSE
OUTPUT "Found at ", FoundAt
ENDIF
-1can never be a valid index, so it means "not found". Initialise it before the loop and test it after. A search that never says "not found" loses a mark.
선형 탐색(linear search)은 다음 중 어떤 방식으로 값을 찾습니까?
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
선형 탐색은 시작점에서부터 타겟(또는 끝까지 도달할 때)을 찾을 때까지 요소를 하나씩 검사합니다.
선형 탐색 전에 FoundAt를 -1로 설정하면 루프 후 '찾지 못함'을 보고할 수 있습니다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
-1은 유효한 인덱스가 아니므로 루프 후 변경되지 않으면 타겟이 배열에 없었습니다.
Largest value, and where it is
Largest ← A[1]
Position ← 1
FOR i ← 2 TO n
IF A[i] > Largest THEN
Largest ← A[i]
Position ← i
ENDIF
NEXT i
OUTPUT Largest, " at ", Position
- Start
Largestat the first element, never at 0: the array might be all negative. - The same shape counts or outputs the non-blank elements: compare each with the marker for unused,
""or-1, and count only those that differ.
Bubble sort
- A bubble sort 冒泡排序 makes repeated passes through the array comparing adjacent pairs and swapping those out of order, until a pass makes no swaps.
- After each pass the largest unsorted value has bubbled to the end, so the next pass can stop one place earlier.
REPEAT
Swapped ← FALSE
FOR Index ← 1 TO Limit - 1
IF Data[Index] > Data[Index + 1] THEN
Temp ← Data[Index]
Data[Index] ← Data[Index + 1]
Data[Index + 1] ← Temp
Swapped ← TRUE
ENDIF
NEXT Index
Limit ← Limit - 1
UNTIL Swapped = FALSE

Each pass carries the largest remaining value to the end
버블 정렬 한 번의(pass) 과정과 그 결과를 순서대로 나열하십시오.
난이도 3/5 · 200 코인 + 오늘 첫 완료 시 소액 보너스
플래그를 초기화하고, 스윕 및 스왑을 수행하며, limit을 줄이고, 전체 pass에서 스왑이 없으면 멈춥니다.
Worked example: where the bubble-sort marks are
- The outer loop that repeats until a pass makes no swaps; the
Swappedflag reset toFALSEat the start of each pass and setTRUEinside theIF. - The three-line swap through a temporary variable. Two lines lose a value.
- The shrinking limit, one less each pass, because the largest value has already reached the end.
- In words, for a stepwise-refinement question: repeat until sorted; on each pass compare adjacent pairs; swap any pair out of order; after each pass the largest unsorted value is at the end.
효율적인 버블 정렬에서 어떤 기능이 채점 대상입니까? 모든 해당 항목을 선택하십시오.
난이도 2/5 · 140 코인 + 오늘 첫 완료 시 소액 보너스
플래그, 임시 변수와의 스왑, 감소하는 limit: 이것이 채점 대상입니다. 배열을 복사하는 것은 알고리즘의 일부가 아닙니다.
Worked example: removing and inserting
- Remove an item: find its index with a linear search; move every later element one place towards the start so the gap closes; mark the last element as unused, or reduce the count.
- Insert into a sorted array: find the first index whose element is larger; move that element and every later one one place towards the end, starting from the last; store the new value in the gap.
- Move from the end when opening a gap and from the start when closing one, or you overwrite the value you are about to move.
배열은 인덱스로 접근할 수 있는 동일한 타입의 여러 항목을 저장하지만, 레코드(name)로 접근할 수 있는 (다르거나 같은) 타입의 필드들을 그룹화합니다.
난이도 1/5 · 100 코인 + 오늘 첫 완료 시 소액 보너스
2-D 배열은 격자(행 × 열)에 적합하고, 레코드는 여러 이름 붙은 필드로 설명되는 하나의实体에 적합합니다.
Marks that slip away
[0:99]holds 100 elements. Count both bounds.- An index is an
INTEGER; a declaration needs the type as well as the bounds. Grid[row, column]: row first. Swapping them reads the wrong cell in every nested loop.- A swap needs a temporary variable; a search needs a "not found" path; a bubble sort ends when a pass makes no swaps, not after a fixed number of passes.
You've got it
- an array holds a fixed number of same-type elements under one identifier, reached by an index between the lower and upper bound; count = upper − lower + 1
- 1-D is a list, 2-D is a table
[row, column]walked by nested loops; declare with bounds and type - linear search:
FoundAt ← -1, loop, store the index, test after the loop; largest value: start atA[1], keep the position - bubble sort: passes of adjacent compare-and-swap with a temporary, a
Swappedflag, a shrinking limit, until a pass makes no swaps