IGCSE Edexcel Computer Science: Typical Example Questions Explained | IGCSE Edexcel 计算机:典型例题详解

📚 IGCSE Edexcel Computer Science: Typical Example Questions Explained | IGCSE Edexcel 计算机:典型例题详解

This article walks through a set of carefully selected example questions that frequently appear in IGCSE Edexcel Computer Science examinations. Each section focuses on a core topic, presents a typical problem, and explains the solution step by step. The aim is to deepen understanding of fundamental concepts such as data representation, logic, programming, architecture, networks, and databases, while also building confidence in answering exam-style questions. By working through these worked examples, students can learn how to apply theoretical knowledge to practical problems, avoid common pitfalls, and practice the precise, structured responses that examiners expect.

本文精选了一组在 IGCSE Edexcel 计算机科学考试中反复出现的典型例题,逐题进行详细解析。每个小节围绕一个核心主题,展示一道常见题型,并逐步拆解解题思路。目标是帮助学习者深化对数据表示、逻辑、编程、体系结构、网络和数据库等基础知识的理解,同时提升应对考试题型的信心。通过这些带完整过程的样例,学生能够学会如何将理论知识应用于实际问题,规避常见错误,并训练出阅卷官青睐的准确、结构清晰的答题方式。


1. Binary and Hexadecimal Conversion | 二进制与十六进制转换

Example: Convert the denary number 202 into an 8‑bit binary number and then into hexadecimal. Show all your working.

例题:将十进制数 202 转换为 8 位二进制数,再转换为十六进制数。写出完整过程。

Start by writing the place values for an 8‑bit binary number: 128, 64, 32, 16, 8, 4, 2, 1. Then find the largest power of 2 that fits into 202. 128 is the largest, so put a 1 under 128. Subtract 128 from 202 to get 74. Next, 64 fits into 74, so put a 1 under 64 and subtract to leave 10. 32 does not fit into 10, so put a 0 under 32. 16 does not fit, another 0. 8 fits into 10, so 1 under 8 and subtract to leave 2. 4 does not fit into 2, so 0 under 4. 2 fits exactly, so 1 under 2 and subtract to leave 0. Finally, 1 does not fit, so 0 under 1. The 8‑bit binary is therefore 11001010₂.

先写出 8 位二进制数的位权:128、64、32、16、8、4、2、1。找出能放进 202 的最大 2 的幂,128 可以,对应位写 1。202 − 128 = 74。接下来 64 能放进 74,对应位写 1,减去后剩 10。32 放不进 10,写 0。16 也放不进,再写 0。8 能放进 10,写 1,剩下 2。4 放不进 2,写 0。2 刚好放进 2,写 1,剩余 0。1 放不进 0,写 0。得到的 8 位二进制为 11001010₂。

To convert 11001010₂ to hexadecimal, split the binary number into groups of four bits, starting from the right: 1100₂ and 1010₂. The left group 1100₂ is 8 + 4 = 12, which is C in hex. The right group 1010₂ is 8 + 2 = 10, which is A in hex. Therefore, 202 in hexadecimal is CA₁₆.

将 11001010₂ 转换成十六进制时,从右向左四位一组分组:1100₂ 和 1010₂。左组 1100₂ 是 8 + 4 = 12,十六进制用 C 表示。右组 1010₂ 是 8 + 2 = 10,十六进制用 A 表示。所以 202 的十六进制为 CA₁₆。


2. Binary Addition and Overflow | 二进制加法与溢出

Example: Add the two 8‑bit binary numbers 01101101₂ and 01011011₂. State whether an overflow occurs and justify your answer.

例题:将两个 8 位二进制数 01101101₂ 与 01011011₂ 相加。说明是否发生溢出并解释理由。

Perform column addition from right to left, carrying bits where the sum is 2 or more. For the least significant bit: 1 + 1 = 2, so write 0 and carry 1. Next column: 0 + 1 + carry 1 = 2, write 0, carry 1. Continue: 1 + 0 + carry 1 = 2, write 0, carry 1; 1 + 1 + carry 1 = 3, write 1, carry 1; 0 + 0 + carry 1 = 1, write 1, no carry; 1 + 1 = 2, write 0, carry 1; 1 + 0 + carry 1 = 2, write 0, carry 1; 0 + 1 + carry 1 = 2, write 0, carry 1. The result is 11001000₂.

从右向左逐列相加,逢 2 进位。最低位:1 + 1 = 2,写 0 进 1。下一列:0 + 1 + 进 1 = 2,写 0 进 1。继续:1 + 0 + 进 1 = 2,写 0 进 1;1 + 1 + 进 1 = 3,写 1 进 1;0 + 0 + 进 1 = 1,写 1 无进位;1 + 1 = 2,写 0 进 1;1 + 0 + 进 1 = 2,写 0 进 1;0 + 1 + 进 1 = 2,写 0 进 1。结果为 11001000₂。

Both original numbers are positive (MSB = 0). The sum of two positive numbers is also expected to be positive, which requires an MSB of 0. In our result, the MSB is 1, which indicates a negative number in two’s complement interpretation. This contradiction is a clear sign of overflow. The carry out of the most significant bit was 1, while the carry into it was 0, confirming overflow for 8‑bit signed arithmetic.

两个原始数的符号位(MSB)都是 0,均为正数。两正数相加期望得到正数,即结果 MSB 应为 0。而我们的结果 MSB 为 1,在二进制补码解释下代表负数。这一矛盾明确说明发生了溢出。最高位进位为 1,但进入最高位的进位为 0,这进一步确认了 8 位有符号运算的溢出。


3. Logic Gates and Truth Tables | 逻辑门与真值表

Example: A circuit has inputs A, B and C. The output X is true when exactly two of the inputs are true. Draw the truth table for X and write a Boolean expression using AND, OR and NOT gates.

例题:一个电路有输入 A、B、C。当恰好有两个输入为真时,输出 X 为真。画出 X 的真值表,并用 AND、OR、NOT 门写出布尔表达式。

Construct a truth table with all 2³ = 8 combinations. For each row, count the number of 1s among A, B, C. X = 1 only if that count equals 2. The rows satisfying the condition are: A=0, B=1, C=1; A=1, B=0, C=1; A=1, B=1, C=0. For the other five combinations, X = 0.

构建包含 2³ = 8 种组合的真值表。统计每行中 A、B、C 的 1 的个数,只有当个数为 2 时 X = 1。满足条件的行是:A=0、B=1、C=1;A=1、B=0、C=1;A=1、B=1、C=0。其余五行 X = 0。

One way to write the expression is to AND the inputs for each true row, ensuring the correct state of each variable. For (0,1,1): NOT A AND B AND C. For (1,0,1): A AND NOT B AND C. For (1,1,0): A AND B AND NOT C. The final output is the OR of these three terms: X = (¬A ∧ B ∧ C) ∨ (A ∧ ¬B ∧ C) ∨ (A ∧ B ∧ ¬C). Using the required notation, X = (NOT A AND B AND C) OR (A AND NOT B AND C) OR (A AND B AND NOT C).

写出表达式的一种方法是将每个使输出为 1 的行对应的变量状态用 AND 组合,确保每个变量取正确的原值或反值。对于 (0,1,1):NOT A AND B AND C。对于 (1,0,1):A AND NOT B AND C。对于 (1,1,0):A AND B AND NOT C。最终输出为这三项的 OR:X = (¬A ∧ B ∧ C) ∨ (A ∧ ¬B ∧ C) ∨ (A ∧ B ∧ ¬C)。用题目要求的形式,X = (NOT A AND B AND C) OR (A AND NOT B AND C) OR (A AND B AND NOT C)。


4. Programming Basics: Variables and Data Types | 编程基础:变量与数据类型

Example: A program stores the name, age and test score of a student. Suggest appropriate data types for each variable and write a short code snippet (in pseudocode or Python) that declares these variables and assigns sample values. Explain what would happen if the age were stored as a string instead of an integer.

例题:一个程序需要存储学生的姓名、年龄和测验分数。请为每个变量建议合适的数据类型,并写一段简短的伪代码或 Python 代码来声明这些变量并赋示例值。解释如果年龄被存储为字符串而不是整数会发生什么。

Name should be a string (text), age an integer (whole number), and test score could be an integer or a real/float (to allow decimal marks). In Python: name = "Alice", age = 16, score = 87.5. In pseudocode: SET name TO “Alice”, SET age TO 16, SET score TO 87.5.

姓名应为字符串,年龄为整数,分数可以是整数或浮点数(以允许小数)。Python 示例:name = "Alice"age = 16score = 87.5。伪代码:SET name TO “Alice”,SET age TO 16,SET score TO 87.5。

If age were stored as a string, arithmetic operations such as incrementing age by one year would not work directly. For instance, age = age + 1 would cause a type error in most languages, because you cannot add a number to a string without explicit conversion. Comparison operations would also behave unexpectedly: “16” sorted lexicographically might come after “100”, which is logically wrong for numeric ages.

若年龄存为字符串,对年龄加 1 等算术操作将无法直接进行。例如 age = age + 1 在多数语言中会引发类型错误,因为不能将数字与字符串直接相加而不进行显式转换。比较操作也会出现异常:按字符串排序时,”16″ 可能排在 “100” 之后,这在数值年龄中是不正确的逻辑。


5. Selection and Iteration | 选择与迭代结构

Example: Write an algorithm (pseudocode) that asks the user to enter 10 numbers. It should count and output how many of them are positive and how many are negative. Zero is neither positive nor negative.

例题:编写一个算法(伪代码),要求用户输入 10 个数字。统计并输出其中有多少个正数、多少个负数。零既不是正数也不是负数。

A count‑controlled loop must execute exactly 10 times. Before the loop, initialise two counters: posCount ← 0, negCount ← 0. Inside the loop: INPUT num; IF num > 0 THEN posCount ← posCount + 1 ELSE IF num < 0 THEN negCount ← negCount + 1 ENDIF. After the loop, OUTPUT posCount, negCount.

必须使用计数控制循环,精确运行 10 次。循环前初始化两个计数器:posCount ← 0、negCount ← 0。循环体内:INPUT num;IF num > 0 THEN posCount ← posCount + 1 ELSE IF num < 0 THEN negCount ← negCount + 1 ENDIF。循环结束后,OUTPUT posCount 和 negCount。

This uses nesting of selection inside iteration. The condition for zero is purposely ignored since the question states it is neither. The algorithm avoids counting zero in either category. An alternative approach could use a FOR loop: FOR i FROM 1 TO 10 DO … ENDFOR. Both styles are acceptable in pseudocode, but the structure must clearly show the sequence, selection and iteration constructs.

这使用了在选择结构中嵌套迭代。零的情况有意忽略,因为题目规定其既非正也非负。算法避免了将零计入任何一类。另一种方式是使用 FOR 循环:FOR i FROM 1 TO 10 DO … ENDFOR。在伪代码中两种写法均可接受,但结构必须清晰地展示顺序、选择和迭代构造。


6. Pseudocode Algorithms | 伪代码算法

Example: A list of 100 names is stored in an array NAMES[1..100]. Write an algorithm to search for the name “Edexcel” and output its index. If not found, output “Not found”. Use linear search.

例题:一个包含 100 个名字的列表存储在数组 NAMES[1..100] 中。编写算法查找名字 “Edexcel” 并输出其索引。如果未找到则输出 “Not found”。使用线性搜索。

SET found ← FALSE, SET index ← 1. WHILE found = FALSE AND index <= 100 DO IF NAMES[index] = "Edexcel" THEN found ← TRUE ELSE index ← index + 1 ENDIF ENDWHILE. IF found THEN OUTPUT index ELSE OUTPUT "Not found".

SET found ← FALSE,SET index ← 1。WHILE found = FALSE AND index <= 100 DO IF NAMES[index] = "Edexcel" THEN found ← TRUE ELSE index ← index + 1 ENDIF ENDWHILE。IF found THEN OUTPUT index ELSE OUTPUT "Not found"。

This algorithm examines each element in turn. When the target is found, the loop terminates, leaving index pointing to the position. If the loop finishes without finding the name, found remains FALSE and the appropriate message is printed. This demonstrates a standard linear search with early exit.

此算法逐个检查元素。找到目标时,循环终止,index 停留在目标位置。若循环结束仍未找到,found 保持 FALSE 并输出相应消息。这展示了一种带提前退出的标准线性搜索。


7. Arrays and Linear Search | 数组与线性搜索

Example: An array SCORES stores integer test marks for 30 students. Write a program fragment that finds the highest mark and the lowest mark. (Use a trace table to verify with sample data if needed.)

例题:数组 SCORES 存储了 30 名学生的整数测验分数。编写一段程序,找出最高分和最低分。(若需要,可用样本数据通过 trace table 验证。)

SET maxScore ← SCORES[0], SET minScore ← SCORES[0]. FOR i FROM 1 TO 29 DO IF SCORES[i] > maxScore THEN maxScore ← SCORES[i] ENDIF; IF SCORES[i] < minScore THEN minScore ← SCORES[i] ENDIF ENDFOR. OUTPUT maxScore, minScore.

SET maxScore ← SCORES[0],SET minScore ← SCORES[0]。FOR i FROM 1 TO 29 DO IF SCORES[i] > maxScore THEN maxScore ← SCORES[i] ENDIF;IF SCORES[i] < minScore THEN minScore ← SCORES[i] ENDIF ENDFOR。OUTPUT maxScore 和 minScore。

We assume 0‑based indexing (first element at index 0). By initialising both max and min to the first element, we avoid using arbitrary starting values that might not be present in the data. The loop runs from the second element to the end, updating max and min whenever a larger or smaller value is encountered. A trace table would show how the variables change as each array element is processed.

这里假设基于 0 的索引(首个元素索引为 0)。将 max 和 min 同时初始化为第一个元素,避免了使用可能不在数据中的任意起始值。循环从第二个元素运行至末尾,遇到更大或更小的值时更新 max 和 min。Trace table 可展示处理每个数组元素时变量的变化过程。


8. Computer Architecture: Fetch-Decode-Execute Cycle | 计算机体系结构:取指-解码-执行周期

Example: Describe the steps of the fetch‑decode‑execute cycle in a von Neumann architecture. In your answer, refer to the program counter (PC), memory address register (MAR), memory data register (MDR), current instruction register (CIR), and the accumulator (ACC).

例题:描述冯·诺依曼体系结构中取指-解码-执行周期的步骤。回答中提及程序计数器(PC)、存储器地址寄存器(MAR)、存储数据寄存器(MDR)、当前指令寄存器(CIR)以及累加器(ACC)。

Fetch step: The address of the next instruction is copied from the PC into the MAR. The PC is then incremented to point to the subsequent instruction. The control unit sends a read signal to main memory, and the instruction stored at the address in MAR is transferred into the MDR. The instruction is then moved to the CIR.

取指步骤:下一条指令的地址从 PC 复制到 MAR。之后 PC 递增,指向下一条指令。控制单元向主存发送读信号,存放在 MAR 中地址处的指令被送入 MDR。随后指令移入 CIR。

Decode step: The control unit decodes the instruction held in the CIR. It identifies the opcode and the operand(s), determining what operation is to be performed and on which data.

解码步骤:控制单元对 CIR 中的指令进行解码,识别操作码与操作数,确定要执行的操作及其作用数据。

Execute step: The instruction is carried out. If it is an arithmetic operation (e.g., ADD), the operand is fetched from memory (again using MAR/MDR) and the calculation is performed, with the result stored in the accumulator. If it is a load/store instruction, data is transferred between the accumulator and memory. After execute, the cycle repeats for the next instruction pointed to by the PC.

执行步骤:实施该指令。若是算术运算(如 ADD),则通过 MAR/MDR 从内存中取操作数,完成计算,结果存入累加器。若是加载/存储指令,则在累加器与内存之间传递数据。执行完毕后,周期根据 PC 指向的新地址重复。


9. Networks: IP and MAC Addresses | 网络:IP 与 MAC 地址

Example: A computer with IP address 192.168.1.25 and MAC address 00-1A-2B-3C-4D-5E sends a data packet to a server with IP address 10.0.0.5 on a different network. Explain how IP and MAC addresses are used at different stages of this transmission, particularly when the packet passes through a router.

例题:一台 IP 地址为 192.168.1.25、MAC 地址为 00-1A-2B-3C-4D-5E 的计算机,向位于不同网络的 IP 地址 10.0.0.5 的服务器发送数据包。解释在此传输过程的不同阶段中 IP 与 MAC 地址各自如何使用,尤其当数据包经过路由器时。

IP addresses identify devices across different networks and remain constant from source to destination (they are logical addresses). MAC addresses identify devices on the same local network (they are physical addresses) and change hop by hop. When the source computer prepares the frame, it uses its own MAC as source and the MAC of its default gateway (router) as destination, while the IP packet keeps the final source and destination IPs.

IP 地址用于跨网络标识设备,从源到目的保持不变(逻辑地址)。MAC 地址用于同一本地网络中的设备标识(物理地址),每跳都可能变化。源计算机封装帧时,用自己的 MAC 作源地址,用默认网关(路由器)的 MAC 作目的地址;而 IP 包始终保留最终的源 IP 和目的 IP。

At the router, the frame is de‑encapsulated: the router reads the destination IP address, looks up its routing table, and determines the next hop. It then re‑encapsulates the IP packet into a new frame, setting its own outgoing interface MAC as the source and the next-hop device’s MAC as the destination. This process repeats until the packet reaches the destination network, where the final router delivers it using the destination device’s MAC. Thus, MAC addresses deliver frames within LANs, while IP addresses deliver packets end‑to‑end.

数据到达路由器后,帧被解封装:路由器读取目的 IP,查路由表确定下一跳。随后将 IP 包重新封装进新帧,将自己的出接口 MAC 作为源,下一跳设备的 MAC 作为目的。此过程重复直至数据包到达目标网络,最终路由器使用目标设备的 MAC 进行交付。因此,MAC 地址在局域网内交付帧,而 IP 地址实现端到端交付。


10. Databases: SQL Queries | 数据库:SQL 查询

Example: A table STUDENTS has fields: StudentID (integer), Name (text), YearGroup (integer), and TutorGroup (text). Write SQL statements to: (a) select all students in Year 11; (b) select the Name and TutorGroup of students not in Year 10; (c) insert a new student with ID 1053, name “Emily”, year 9, tutor “9B”.

例题:STUDENTS 表含有字段:StudentID(整数)、Name(文本)、YearGroup(整数)、TutorGroup(文本)。写出 SQL 语句完成:(a) 选择所有 Year 11 的学生;(b) 选择不在 Year 10 的学生的 Name 和 TutorGroup;(c) 插入一名新学生,ID 1053,姓名 “Emily”,年级 9,导师组 “9B”。

(a) SELECT * FROM STUDENTS WHERE YearGroup = 11; (b) SELECT Name, TutorGroup FROM STUDENTS WHERE YearGroup <> 10; or using !=. (c) INSERT INTO STUDENTS (StudentID, Name, YearGroup, TutorGroup) VALUES (1053, 'Emily', 9, '9B');

(a) SELECT * FROM STUDENTS WHERE YearGroup = 11; (b) SELECT Name, TutorGroup FROM STUDENTS WHERE YearGroup <> 10; 或用 !=。(c) INSERT INTO STUDENTS (StudentID, Name, YearGroup, TutorGroup) VALUES (1053, 'Emily', 9, '9B');

These simple queries illustrate the SELECT, FROM, WHERE, INSERT INTO, and VALUES clauses. It is important to match data types: strings are enclosed in single quotes, integers are not. The WHERE clause filters records according to a condition; the INSERT statement specifies columns and corresponding values in order.

这些简单查询展示了 SELECT、FROM、WHERE、INSERT INTO 和 VALUES 子句。务必匹配数据类型:字符串用单引号括起,整数则不用。WHERE 子句根据条件筛选记录;INSERT 语句按顺序指定列和相应值。

Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading