A programmer needs to document an algorithm that calculates the area of a circle. The requirements are:
1. Input the radius (\(r\)).
2. Check if \(r\) is greater than 0.
3. If valid, calculate \(Area = 3.14159 \times r^{2}\).
4. Output the result.
Which tool uses standard geometric symbols such as parallelograms for input/output and diamonds for decisions to represent this logic?
Cambridge International AS Level · Computer Science (9618)
Algorithm Design and Problem-solving:练习题
5 道选择题即时批改,另有 5 道文字题附完整解题步骤,全部围绕「Algorithm Design and Problem-solving」。
Study the following pseudocode snippet:Total ← 0
FOR i ← 1 TO 5
INPUT Value
IF Value > 10 THEN
Total ← Total + 1
ENDIF
NEXT i
If the input values are 5, 12, 10, 15, and 8, what will be the final value of Total?
Consider the following pseudocode intended to find the smallest value in an array List with indices from 1 to 10:Min ← List[1]
FOR Index ← 2 TO 10
IF List[Index] < Min THEN
Min ← List[Index]
ENDIF
NEXT Index
If List contains the values [40, 30, 50, 20, 20, 10, 60, 5, 80, 100], how many times will the assignment Min ← List[Index] be executed?
An algorithm is being developed using stepwise refinement. Which of the following best describes this process?
A programmer is designing an algorithm to process a list of 500 employee names stored in a 1D array. The names are currently unsorted. The goal is to find the position of a specific name, "Zackary", within the array.
Which search algorithm must be used in this scenario, and what is the maximum number of comparisons required to determine if the name is not in the list?
In the context of Algorithm Design and Problem-solving, identify the computational thinking technique that involves hiding unnecessary details to focus on the essential characteristics required for a specific purpose.
先自己写一遍答案,再对照解题步骤。
Consider the following pseudocode snippet that performs a linear search on an array Data[1:5] containing the values [12, 7, 25, 14, 9]:Found ← FALSE
Index ← 1
WHILE Index <= 5 AND NOT Found
IF Data[Index] = 14 THEN
Found ← TRUE
ELSE
Index ← Index + 1
ENDIF
ENDWHILE
What is the final value of Index when the loop terminates?
先自己写一遍答案,再对照解题步骤。
A linked list is implemented using a 1D array of records. The list contains three nodes with StartPointer = 2:
- List[1]: Data = "Cat", NextPointer = -1
- List[2]: Data = "Apple", NextPointer = 3
- List[3]: Data = "Banana", NextPointer = 1
What is the third data value accessed when traversing the linked list from the start pointer?
先自己写一遍答案,再对照解题步骤。
A software developer is creating a computerized model of a city's public transport system. During the design phase, the developer applies abstraction and decomposition.
(a) Explain the purpose of abstraction when creating this model. (2 points)
(b) Suggest two details that would be essential to include in the model and two details that could be ignored through abstraction. (2 points)
(c) The task "Calculate Journey Time" needs to be broken down. Use decomposition to identify two sub-tasks that would be required to calculate the total travel time between two bus stops. (2 points)
先自己写一遍答案,再对照解题步骤。
Consider the following pseudocode function:
FUNCTION CalculateScore(Data[1:4] : INTEGER) RETURNS INTEGER
DECLARE Result : INTEGER
Result ← 0
FOR i ← 1 TO 4
IF Data[i] MOD 2 <> 0 THEN
Result ← Result + (Data[i] * 2)
ELSE
Result ← Result + (Data[i] DIV 2)
ENDIF
NEXT i
RETURN Result
ENDFUNCTION
If the array passed to the function contains the values [3, 8, 5, 4], what is the value returned by the function?
先自己写一遍答案,再对照解题步骤。
* thinka提供的内容由AI生成,可能并非总是准确或最新。请将其用作辅助资源,并与官方材料进行核实。
想多做几道同类题目?立即开始练习这个课题,边做边批改。
立即练习