Senior Secondary (HKDSE) · Information and Communication Technology

Programming :練習問題

その場で採点される選択問題 5 問と、解説つきの記述問題 5 問。すべて「Programming 」からの出題です。

10 問27 無料・登録不要
問 1
1

Consider the following pseudocode snippet:


DECLARE x AS INTEGER
DECLARE y AS INTEGER
DECLARE result AS INTEGER

x = 25
y = 7
result = (x MOD y) + (x DIV y)

PRINT result

What will be the final value displayed by the program?

問 2
1

Consider the following pseudocode:


GLOBAL A = 20

SUBROUTINE UpdateValue(B)
A = A - B
B = B + 1
END SUBROUTINE

START
C = 7
CALL UpdateValue(C)
PRINT A
PRINT C
END START

If parameters are passed by value, what will be the output of PRINT A and PRINT C, respectively?

問 3
1

A program calculates the average of a list of numbers provided by the user. The user is prompted to enter five numbers. If the user accidentally enters '0' as one of the numbers, and the program performs a division by the count of numbers entered (which is 5), what type of error will occur if the program logic incorrectly attempts to sum numbers, but fails to handle specific numeric inputs or the count of valid numbers?

問 4
1

When developing a software project, a programmer decides to use comments and proper indentation throughout the source code. According to the syllabus, which of the following best describes the primary purpose of these practices?

問 5
1

Consider the following pseudocode for a linear search algorithm:


DECLARE numbers[5] AS INTEGER
numbers = [25, 10, 30, 15, 5]
DECLARE target AS INTEGER
target = 15
DECLARE foundIndex AS INTEGER
foundIndex = -1

FOR i FROM 0 TO 4 DO
IF numbers[i] == target THEN
foundIndex = i
BREAK
END IF
END FOR

PRINT foundIndex

What value will be displayed by the program?

問 6
2

Explain one reason why using meaningful variable names (e.g., totalScore instead of ts) is considered good programming style.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 7
4

A programmer is developing a module to process a list of integers. Compare Bubble Sort and Selection Sort in terms of their worst-case time complexity using Big O notation, and explain one reason why a programmer might choose to use Insertion Sort instead of these for a list that is already nearly sorted.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 8
5

A simple linear queue implementation uses an array Q of size \(N=10\) (indices 0 to 9), with pointers front and rear both initialized to 0. The rear pointer tracks the index of the next available slot for insertion. If 10 successful elements are inserted followed by 5 successful deletion operations, state the resulting values of front and rear. Also, explain the key limitation preventing further insertions and the technical term describing this inefficient usage of the array space.

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 9
4

Consider the following pseudocode:

GLOBAL X = 10

SUBROUTINE Process(Y)
X = X + Y
Y = Y * 2
END SUBROUTINE

START
A = 5
CALL Process(A)
OUTPUT X
OUTPUT A
END START

(a) What will be the output of OUTPUT X and OUTPUT A if parameters are passed by value?

(b) What will be the output of OUTPUT X and OUTPUT A if parameters are passed by reference?

まず自分で答えを書いてから、解説と照らし合わせましょう。

問 10
7

A queue data structure can be implemented using a one-dimensional array. Assume a linear array queueArray of fixed size $$N=5$$ is used, with front and rear pointers tracking the head and tail of the queue, respectively. Initially, the queue is empty, with front = -1 and rear = -1.

(a) Design algorithms using pseudocode for the following operations. Ensure you handle conditions where the queue might be full or empty.

(i) ENQUEUE(item): Adds an item to the rear of the queue.

(ii) DEQUEUE(): Removes and returns an item from the front of the queue.

(b) Trace the execution of the following sequence of operations on the initially empty queue. For each step, show the values of front, rear, and the content of queueArray. Use '_' to denote an empty slot in the array.

1. ENQUEUE('A')
2. ENQUEUE('B')
3. DEQUEUE()
4. ENQUEUE('C')
5. ENQUEUE('D')
6. DEQUEUE()
7. ENQUEUE('E')
8. ENQUEUE('F')

(c) Explain one major limitation of implementing a queue using a simple linear array (as described above) and how a circular queue implementation addresses this limitation.

まず自分で答えを書いてから、解説と照らし合わせましょう。

※ thinkaのコンテンツはAIにより生成されているため、内容が正確でない場合があります。補助教材としてご使用いただき、公式の教材と合わせてご確認ください。

模範解答は見ました。次はあなたの答案を採点します。

このページは良い答案の形を示せますが、あなたの答案に何が足りないかは教えられません。thinka は実際の採点基準に沿って記述答案を約 15 秒で採点します。

同じような問題をもっと解きたい?このトピックの新しい問題を、解きながら採点。

練習を始める