A linear search algorithm is used to find the value 25 in the following list: [10, 5, 25, 40, 15].
Assuming the algorithm stops as soon as the item is found, how many comparisons are made?
Oxford AQA International A-level · Computer Science (9645)
Following and writing algorithms: แบบฝึกหัด
ข้อปรนัย 5 ข้อ ตรวจให้ทันทีที่ตอบ และข้อเขียน 5 ข้อ พร้อมวิธีทำละเอียด ทั้งหมดจากเรื่อง Following and writing algorithms
Which of the following statements accurately compares the worst-case time efficiency of Binary Search and Linear Search on a very large, sorted list containing \(n\) elements?
Hand-trace the following algorithm and determine the final value of B:A = 6B = 1REPEAT A = A - 2 B = B * 3UNTIL B > A
What is the defining characteristic of an algorithm according to the standard definition in computer science?
Consider the list [8, 3, 6, 1]. After the first complete pass of the bubble sort algorithm (starting from the left and comparing adjacent elements), what is the state of the list?
What is the fundamental characteristic of an algorithm, as defined in computer science?
ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ
Explain the primary purpose of hand-tracing an algorithm using a set of test data.
ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ
Explain the importance of using erroneous test data when hand-tracing an algorithm intended for a production environment.
ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ
Consider the following algorithm expressed in pseudocode:
START
X = 15
Y = 7
Z = 0
IF X > Y THEN
Z = X MOD Y
X = X DIV Y
ELSE
Z = Y - X
X = Y * 2
END IF
Y = Y + Z
OUTPUT X
OUTPUT Y
OUTPUT Z
END
Trace the execution of this algorithm, assuming standard integer arithmetic (DIV is integer division and MOD is the remainder), and state the final output values of X, Y, and Z.
ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ
The following pseudocode processes an array Items of integers. Assume Items = [10, 4, 1, 9, 6] and the array indices run from 1 to 5 (
=5).
FUNCTION ProcessList(Items, n)
1. Total = 0
2. FOR I = 1 TO n DO
3. Current = Items[I]
4. IF Current < 5 AND Current MOD 2 == 0 THEN
5. Total = Total + 1
6. ELSE IF Current >= 10 OR Current MOD 3 == 0 THEN
7. Total = Total + 2
8. ELSE
9. Total = Total + 0
10. END IF
11. END FOR
12. RETURN Total
Hand-trace the execution of ProcessList(Items, 5) and state the final value returned by the function.
ลองเขียนคำตอบด้วยตัวเองก่อน แล้วค่อยเทียบกับวิธีทำ
* เนื้อหาของ thinka สร้างโดย AI อาจไม่ถูกต้องสมบูรณ์ในทุกกรณี กรุณาใช้เป็นสื่อเสริมและตรวจสอบกับเอกสารอ้างอิงอย่างเป็นทางการ
คุณเห็นเฉลยแล้ว ทีนี้มาตรวจคำตอบของคุณบ้าง
หน้านี้บอกได้ว่าคำตอบที่ดีเป็นอย่างไร แต่บอกไม่ได้ว่าคำตอบของคุณขาดอะไร thinka ตรวจข้อเขียนของคุณตามเกณฑ์ให้คะแนนจริงในราว 15 วินาที
อยากฝึกโจทย์แบบนี้เพิ่มไหม เริ่มฝึกหัวข้อนี้ได้เลย ตรวจให้ทันทีทุกข้อ
เริ่มฝึกเลย