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 วินาที

อยากฝึกโจทย์แบบนี้เพิ่มไหม เริ่มฝึกหัวข้อนี้ได้เลย ตรวจให้ทันทีทุกข้อ

เริ่มฝึกเลย