Free Material: FE Linked List
Try a Real Exam Question: A Singly Linked List Stored in Two Arrays
過去問を解いてみよう:配列で表した「単方向リスト」
Kakomon o toite miyou: hairetsu de arawashita 「tanhoukou risuto」
Free Study Materials › Fundamental Information Technology Engineer Examination
A walkthrough of one real past exam question published by the Information-technology Promotion Agency, Japan (IPA), explained in Japanese with romanization and in American English.
This page shows the full question and explanation. The question text is shown in English first, followed by the Japanese original and its romanization.
Fundamental Information Technology Engineer Examination, Subject B Public Question
基本情報技術者試験 科目B 公開問題
Kihon-jouhou Gijutsusha Shiken Kamoku B Koukai Mondai
Question
In the following program, choose the correct combination of answers for [a] and [b] from the answer choices. Here, array element numbers start at 1.
次のプログラム中の[a]と[b]に入れる正しい答えの組合せを,解答群の中から選べ。ここで,配列の要素番号は1から始まる。
Tsugi no puroguramu-chuu no [a] to [b] ni ireru tadashii kotae no kumiawase o, kaitou-gun no naka kara erabe. Koko de, hairetsu no youso bangou wa 1 kara hajimaru.
A singly linked list is represented by two arrays, dataList and pointerList. dataList stores the values of the list elements, and pointerList stores the element number of dataList that corresponds to the next element of the list. The head of the singly linked list is the pair dataList[1] and pointerList[1]. The element of pointerList that corresponds to the tail of the list is undefined. The elements of dataList that do not hold a value of the list, and the corresponding elements of pointerList, are undefined.
単方向リストを,配列dataListと配列pointerListの二つの配列で表現する。dataListにリストの要素の値を格納し,pointerListにリストの次の要素に対応するdataListの要素番号を格納する。単方向リストの先頭は,dataList[1]及びpointerList[1]の組みである。単方向リストの末尾に対応するpointerListの要素は未定義である。dataListのうち単方向リストの要素の値を格納していない要素と,対応するpointerListの要素は未定義である。
Tanhoukou risuto o, hairetsu dataList to hairetsu pointerList no futatsu no hairetsu de hyougen suru. dataList ni risuto no youso no atai o kakunou shi, pointerList ni risuto no tsugi no youso ni taiou suru dataList no youso bangou o kakunou suru. Tanhoukou risuto no sentou wa, dataList[1] oyobi pointerList[1] no kumi de aru. Tanhoukou risuto no matsubi ni taiou suru pointerList no youso wa miteigi de aru. dataList no uchi tanhoukou risuto no youso no atai o kakunou shite inai youso to, taiou suru pointerList no youso wa miteigi de aru.
Figure 1 shows the contents of dataList and pointerList handled by the program. The element number of the element after the head is 3, stored in pointerList[1], and its value is 20, stored in dataList[3]. The element number of the next element is 2, stored in pointerList[3], and its value is 30, stored in dataList[2].
プログラムが扱うdataList及びpointerListの内容を図1に示す。先頭の次の要素の要素番号は,pointerList[1]に格納された3であり,値はdataList[3]に格納された20である。その次の要素の要素番号はpointerList[3]に格納された2であり,値はdataList[2]に格納された30である。
Puroguramu ga atsukau dataList oyobi pointerList no naiyou o zu 1 ni shimesu. Sentou no tsugi no youso no youso bangou wa, pointerList[1] ni kakunou sareta 3 de ari, atai wa dataList[3] ni kakunou sareta 20 de aru. Sono tsugi no youso no youso bangou wa pointerList[3] ni kakunou sareta 2 de ari, atai wa dataList[2] ni kakunou sareta 30 de aru.
| Element number | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| dataList | 10 | 30 | 20 | 40 | undefined |
| pointerList | 3 | 4 | 2 | undefined | undefined |
Note: Shaded cells indicate that the element is undefined.
注記 網掛けはその要素が未定義であることを示す。
Chuuki: Amikake wa sono youso ga miteigi de aru koto o shimesu.
Figure 1: Contents of dataList and pointerList
図1 dataList及びpointerListの内容
Zu 1: dataList oyobi pointerList no naiyou
The function orderList returns an array that stores the values of the singly linked list represented by dataList and pointerList in Figure 1, in order, by following the list from its head. Figure 2 shows the array returned by orderList.
関数orderListは,図1のdataList及びpointerListで表現した単方向リストの値を,単方向リストの先頭からたどって順番に格納した配列を返す。関数orderListが返す配列を図2に示す。
Kansuu orderList wa, zu 1 no dataList oyobi pointerList de hyougen shita tanhoukou risuto no atai o, tanhoukou risuto no sentou kara tadotte junban ni kakunou shita hairetsu o kaesu. Kansuu orderList ga kaesu hairetsu o zu 2 ni shimesu.
| Element number | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| orderList() | 10 | 20 | 30 | 40 |
Figure 2: The array returned by orderList
図2 関数orderListが返す配列
Zu 2: Kansuu orderList ga kaesu hairetsu
How to Read the Program (Supplement)
1. ○ marks the declaration of a function. ← means “put the value on the right into the variable on the left” (assignment).
1 ○は、関数の宣言を表します。←は、右の値を左の変数に入れる(代入する)という意味です。
1 ○ wa, kansuu no sengen o arawashimasu. ← wa, migi no atai o hidari no hensuu ni ireru (dainyuu suru) to iu imi desu.
2. {} is an array with 0 elements. “Undefined” means that no value is stored.
2 {} は、要素が0個の配列です。「未定義」は、値が入っていない状態です。
2 {} wa, youso ga 0-ko no hairetsu desu. 「Miteigi」 wa, atai ga haitte inai joutai desu.
3. for repeats the steps up to endfor while increasing i by 1, from 1 to the number of elements in dataList. “End the loop” (繰返し処理を終了する) stops the for loop right there.
3 for は、i を 1 から dataList の要素数まで 1 ずつ増やしながら、endfor までの処理を繰り返します。「繰返し処理を終了する」と、そこで for の繰返しを終えます。
3 for wa, i o 1 kara dataList no youso-suu made 1 zutsu fuyashinagara, endfor made no shori o kurikaeshimasu. 「Kurikaeshi shori o shuuryou suru」 to, soko de for no kurikaeshi o oemasu.
4. The variable p is the element number of the element you are currently looking at. It starts at 1, the head of the list.
4 変数 p は、いま見ている要素の要素番号です。最初は、先頭の 1 です。
4 Hensuu p wa, ima mite iru youso no youso bangou desu. Saisho wa, sentou no 1 desu.
[Program]
Global: integer array: dataList ← {10, 30, 20, 40, undefined value}
Global: integer array: pointerList ← {3, 4, 2, undefined value, undefined value}
○Integer array: orderList()
Integer: i, p ← 1
Integer array: linearList ← {} // array with 0 elements
for (i from 1 to the number of elements in dataList, increasing by 1)
append the value of dataList[p] to the end of linearList
if ( [a] is undefined)
end the loop
endif
p ← [b]
endfor
return linearList
大域: 整数型の配列: dataList ← {10, 30, 20, 40, 未定義の値}
大域: 整数型の配列: pointerList ← {3, 4, 2, 未定義の値, 未定義の値}
○整数型の配列: orderList()
整数型: i, p ← 1
整数型の配列: linearList ← {} // 要素数0の配列
for (i を 1 から dataListの要素数 まで 1 ずつ増やす)
linearListの末尾 に dataList[p]の値 を追加する
if ( [a] が 未定義)
繰返し処理を終了する
endif
p ← [b]
endfor
return linearList
Taiiki: seisuu-gata no hairetsu: dataList ← {10, 30, 20, 40, miteigi no atai}
Taiiki: seisuu-gata no hairetsu: pointerList ← {3, 4, 2, miteigi no atai, miteigi no atai}
○Seisuu-gata no hairetsu: orderList()
Seisuu-gata: i, p ← 1
Seisuu-gata no hairetsu: linearList ← {} // Youso-suu 0 no hairetsu
for (i o 1 kara dataList no youso-suu made 1 zutsu fuyasu)
linearList no matsubi ni dataList[p] no atai o tsuika suru
if ( [a] ga miteigi)
Kurikaeshi shori o shuuryou suru
endif
p ← [b]
endfor
return linearList
| Choice | a | b |
|---|---|---|
| ア | dataList[p] | i |
| イ | dataList[p] | pointerList[p] |
| ウ | pointerList[p] | i |
| エ | pointerList[p] | pointerList[p] |
Explanation
Correct answer: エ
In a singly linked list, pointerList holds “the element number of the next element.” So, using p, the number of the element you are currently looking at, pointerList[p] takes you to the next element.
単方向リストでは、pointerList に「次の要素の要素番号」が入っています。したがって、いま見ている要素の番号 p を使って、pointerList[p] で次の要素に進めます。
Tanhoukou risuto de wa, pointerList ni 「tsugi no youso no youso bangou」 ga haitte imasu. Shitagatte, ima mite iru youso no bangou p o tsukatte, pointerList[p] de tsugi no youso ni susumemasu.
a (the condition for ending the loop): The element of pointerList that corresponds to the tail of the list is undefined. So when pointerList[p] is undefined, you have reached the tail, and the loop ends.
a(繰返しを終える条件):リストの末尾に対応する pointerList の要素は、未定義です。したがって、pointerList[p] が未定義のときは末尾に着いたので、繰返し処理を終了します。
a (kurikaeshi o oeru jouken): Risuto no matsubi ni taiou suru pointerList no youso wa, miteigi desu. Shitagatte, pointerList[p] ga miteigi no toki wa matsubi ni tsuita node, kurikaeshi shori o shuuryou shimasu.
b (the next element to look at): The element number of the next element is stored in pointerList[p], so set p ← pointerList[p].
b(次に見る要素):次の要素の要素番号は pointerList[p] に入っているので、p ← pointerList[p] とします。
b (tsugi ni miru youso): Tsugi no youso no youso bangou wa pointerList[p] ni haitte iru node, p ← pointerList[p] to shimasu.
How it runs: p moves 1 → 3 → 2 → 4, and the values of dataList[p] are appended in the order 10, 20, 30, 40. When p is 4, pointerList[4] is undefined, so the loop ends there.
実行のようす:p は 1 → 3 → 2 → 4 と進み、dataList[p] の値が 10, 20, 30, 40 の順に追加されます。p が 4 のとき、pointerList[4] は未定義なので、ここで繰返しを終了します。
Jikkou no yousu: p wa 1 → 3 → 2 → 4 to susumi, dataList[p] no atai ga 10, 20, 30, 40 no jun ni tsuika saremasu. p ga 4 no toki, pointerList[4] wa miteigi nanode, koko de kurikaeshi o shuuryou shimasu.
ア: Both a and b are wrong.
ア:a も b も誤りです。
ア: a mo b mo ayamari desu.
イ: b is correct, but if a is dataList[p], the tail cannot be detected. The value of the tail element, 40, is defined, so the loop does not end at the tail and, on the next pass, refers to an undefined element number.
イ:b は正しいですが、a が dataList[p] だと、末尾を見つけられません。末尾の要素の値 40 は定義されているため、末尾で繰返しが終わらず、次の回で未定義の要素番号を参照してしまうからです。
イ: b wa tadashii desu ga, a ga dataList[p] da to, matsubi o mitsukeraremasen. Matsubi no youso no atai 40 wa teigi sarete iru tame, matsubi de kurikaeshi ga owarazu, tsugi no kai de miteigi no youso bangou o sanshou shite shimau kara desu.
ウ: a is correct, but if b is i, the for loop variable i is put into p as it is, so the list is not followed in order and the result does not match Figure 2.
ウ:a は正しいですが、b が i だと、p に for の変数 i をそのまま入れることになり、リストの順にたどれず、図2の結果になりません。
ウ: a wa tadashii desu ga, b ga i da to, p ni for no hensuu i o sono mama ireru koto ni nari, risuto no jun ni tadorezu, zu 2 no kekka ni narimasen.
Download the PDF version
The PDF contains the same content as this page, in Japanese with romanization and in American English. Downloads are free. You may use the PDF for your own study and for educational purposes within your organization. Please do not redistribute, republish, or sell it without our written permission. Please check the official exam guide for the latest exam details.
Source and notes
Source: FY2026 (Reiwa 8) Fundamental Information Technology Engineer Examination, Subject B Public Question 4, Information-technology Promotion Agency, Japan (IPA). The Japanese question text, program, and answer choices are unaltered (the boxes for the blanks are shown as [a] and [b]). Figures 1 and 2 were redrawn by Osuken Inc. based on the original figures. The “How to Read the Program” supplement, the explanation, the romanization, and the English translation were written by Osuken Inc. and are not created or endorsed by IPA.
出典:令和8年度 基本情報技術者試験 科目B 公開問題 問4(独立行政法人情報処理推進機構:IPA)。問題文、プログラム、解答群は原文のまま(空欄の枠は[a][b]で表しています)。図1・図2は、原文の図をもとに、オスケン株式会社が描き直したものです。「プログラムの読み方」と解説、ローマ字と英語は、オスケン株式会社による文・表記・訳で、IPAが作成・承認したものではありません。
Shutten: Reiwa 8-nendo Kihon-jouhou Gijutsusha Shiken Kamoku B Koukai Mondai Mon 4 (Dokuritsu Gyousei Houjin Jouhou-shori Suishin Kikou: IPA). Mondai-bun, puroguramu, kaitou-gun wa genbun no mama (kuuran no waku wa [a] [b] de arawashite imasu). Zu 1, zu 2 wa, genbun no zu o moto ni, Osuken Kabushiki-gaisha ga kakinaoshita mono desu. 「Puroguramu no yomikata」 to kaisetsu, Roomaji to eigo wa, Osuken Kabushiki-gaisha ni yoru bun, hyouki, yaku de, IPA ga sakusei, shounin shita mono de wa arimasen.
© 2025-2026 Osuken Inc. Unauthorized reproduction is prohibited.
More free materials
- Try a Real Exam Question: Fine-Tuning a Large Language Model
- Try a Real Exam Question: Finding the Shortest Project Duration
- Learn About Special Flammables: An Original Practice Question
- Learn About Multiples of the Designated Quantity: An Original Practice Question
- Learn About Types of Combustion: An Original Practice Question
