📚 A-Level Computer Science: Common Mistakes Explained | A-Level 计算机:易错题精讲
In A-Level Computer Science, many students lose marks not because they lack understanding, but because they fall into predictable traps set by exam questions. This article walks through a series of classic error-prone problems across key topics, explaining exactly where candidates go wrong and how to secure full marks. By studying these carefully worked examples, you can sharpen your exam technique and avoid the most common pitfalls.
在A-Level计算机科学中,许多学生丢分并非因为理解不足,而是落入了考题常见的陷阱。本文精选了跨越多个核心主题的典型易错题,精准剖析考生出错的原因,并给出获取满分的正确思路。认真研读这些精心拆解的例题,能够打磨你的应试技巧,避开最常见的失分点。
1. Binary Addition and Overflow Detection | 二进制加法与溢出检测
Many students correctly add two 8-bit binary numbers but fail to determine whether overflow has occurred. Exam questions often ask for both the result and the state of the overflow flag, requiring a clear distinction between unsigned overflow (carry out of the most significant bit) and signed overflow (when adding two numbers with the same sign yields a result with a different sign).
许多学生能正确对两个8位二进制数做加法,却无法判断是否发生溢出。考题常常要求同时给出结果和溢出标志状态,这需要清晰区分无符号溢出(最高位产生进位)和有符号溢出(两个同符号数相加得到不同符号的结果)。
Consider adding 0110 0101 (101 in decimal) and 0011 1101 (61). The sum is 1010 0010, with no carry out from bit 7. A student may wrongly claim “no overflow” for signed numbers; however, both operands are positive, yet the most significant bit of the result is 1, indicating a negative number in two’s complement. This is a classic signed overflow, and the overflow flag should be set.
考虑0110 0101(十进制101)和0011 1101(十进制61)相加。结果是1010 0010,第7位没有进位。学生可能错误地声称有符号数“无溢出”;但实际上两个操作数都是正数,而结果的最高位是1,在补码表示中表示负数。这是典型的有符号溢出,溢出标志应置位。
A robust method: for two’s complement signed addition, overflow occurs if the carry into the sign bit is different from the carry out of the sign bit. In this example, carry into bit 7 is 1, carry out is 0 — inequality, hence overflow. Always state what each flag means in the context of the representation being used.
一个稳健的方法:对于补码有符号加法,如果进入符号位的进位与离开符号位的进位不同,则发生溢出。此例中,进入第7位的进位是1,离开的是0——不相等,因此溢出。务必根据使用的表示法说明每个标志的含义。
2. Bitwise Operators and Mask Creation | 位运算符与掩码构建
Questions involving bitwise AND, OR, XOR, and shifting often test whether you can design a mask to isolate or modify specific bits. A frequent error is confusing the mask value with the desired bit pattern or using the wrong operator for the task — for example, using OR when you need to clear a bit.
涉及按位与、或、异或及移位的题目常考察是否能够设计掩码来隔离或修改特定位。常见错误是混淆掩码值与目标比特模式,或任务选错运算符——例如需要清零时却用了或运算。
To set bit 3 of a register (counting from 0 as the least significant bit) without affecting other bits, you would OR the register with 0000 1000. A common mistake is to use AND with 0000 1000, which would clear all other bits instead of preserving them. To clear bit 3, you would AND with 1111 0111 — the inversion of the mask with that bit set.
要设置寄存器第3位(最低位计为位0)而不影响其他位,应将寄存器与0000 1000做按位或。常见错误是用0000 1000做按位与,这会把其他位都清零而不是保留。要清零第3位,需与1111 0111(即置位掩码的反码)做按位与。
When toggling bits, XOR with a mask containing 1s at the positions to flip. Students sometimes try to achieve toggling with OR, which only sets bits, or with NOT applied incorrectly. Carefully distinguish between bitwise and logical operators; a single ampersand ‘&’ is bitwise, while ‘&&’ evaluates to a Boolean and will not produce a bit pattern.
翻转位时,需将寄存器与在目标位包含1的掩码做异或。学生有时想用或运算实现翻转,那只会置位,或错误地使用取反。务必区分位运算符和逻辑运算符;单与号’&’是按位与,而’&&’求值后得到布尔值,不会产生比特模式。
3. Trace Tables for Recursive Subroutines | 递归子程序的跟踪表
Exam questions may present a short recursive function and ask you to complete a trace table showing variable states and return values at each call. A very common slip is to incorrectly unwind the stack, forgetting that local variables are restored when a call returns.
考题可能给出一小段递归函数,要求填写跟踪表以展示每次调用时的变量状态和返回值。一个极常见的失误是错误地展开调用栈,忘记在返回时恢复局部变量。
Consider a function factorial(n) that returns 1 if n=0 else n * factorial(n-1). When tracing factorial(3), each recursive call pushes a new frame with its own n. Upon hitting factorial(0) and returning 1, the control goes back to factorial(1) where n was 1, not 0. Some students incorrectly overwrite the calling frame’s n with the returned value, leading to a nonsensical trace.
考虑函数factorial(n),若n=0返回1,否则返回n * factorial(n-1)。跟踪factorial(3)时,每次递归调用压入新帧,拥有自己的n。当遇到factorial(0)并返回1后,控制回到factorial(1),其中n是1而非0。有些学生错误地用返回值覆盖调用帧的n,导致跟踪结果毫无意义。
Always maintain separate columns for each level of recursion or show the call stack explicitly. Mark the return value and identify which call receives it. Practice drawing the stack frames as a visual aid: each frame contains local variables and a placeholder for the result to be computed after the recursive call returns.
始终保持递归层次独立的列,或显式描绘调用栈。标记返回值,并明确哪个调用接收它。练习绘制栈帧作为可视化辅助:每个帧包含局部变量和一个占位符,用以存放递归调用返回后待计算的结果。
4. SQL JOIN Conditions and Missing Data | SQL 连接条件与缺失数据
SQL questions frequently trap students who confuse INNER JOIN with LEFT or RIGHT JOIN. When a query requires retaining all rows from one table even if there is no match in the other, using INNER JOIN discards unmatched rows, causing marks to be lost.
SQL题常令混淆内连接与左/右连接的学生落入陷阱。当查询需要保留一个表的所有行,即使另一表无匹配时,使用内连接会丢弃不匹配的行,导致失分。
Suppose you have tables Student(StudentID, Name) and Exam(StudentID, Subject, Grade). To list every student’s name alongside their Maths grade, including those who have not taken Maths, you must use LEFT JOIN Student ON Student.StudentID = Exam.StudentID AND Subject = ‘Maths’. A common wrong answer uses INNER JOIN or places the Subject condition in the WHERE clause, which turns the left join into an inner join because WHERE filters out NULLs.
假设有表Student(StudentID, Name)和Exam(StudentID, Subject, Grade)。要列出每位学生的姓名及其数学成绩,包括未考数学者,必须使用LEFT JOIN Student ON Student.StudentID = Exam.StudentID AND Subject = ‘Maths’。常见错误答案是使用INNER JOIN,或将Subject条件放入WHERE子句,这会把左连接变成内连接,因为WHERE会过滤掉NULL。
Additionally, mishandling NULL in aggregate functions confuses many. COUNT(*) counts rows regardless of NULLs, whereas COUNT(column) counts only non-NULL values. When checking for students with no Maths exam, remember that Exam.StudentID will be NULL in the result set of a left join; testing ‘WHERE Exam.StudentID IS NULL’ correctly identifies such students.
此外,聚合函数中对NULL的错误处理令许多人困惑。COUNT(*)计算行数时忽略NULL与否,而COUNT(列)只计算非NULL值。检查未参加数学考试的学生时,记住在左连接的结果集中Exam.StudentID将为NULL;用’WHERE Exam.StudentID IS NULL’可正确识别这些学生。
5. Simplifying Boolean Expressions with De Morgan’s Laws | 用德摩根定律化简布尔表达式
De Morgan’s laws: NOT (A AND B) = (NOT A) OR (NOT B); NOT (A OR B) = (NOT A) AND (NOT B). A typical error when simplifying gate circuits or logic expressions is to apply De Morgan’s laws to part of an expression without maintaining the correct parenthesisation, or to forget that double negation cancels.
德摩根定律:NOT (A AND B) = (NOT A) OR (NOT B);NOT (A OR B) = (NOT A) AND (NOT B)。化简门电路或逻辑表达式时的典型错误是对部分表达式应用德摩根定律时未能保持正确的括号层级,或忘记双重否定抵消。
For the expression NOT ( (A AND B) OR NOT C ), students may incorrectly distribute the outer NOT to each literal without changing the operator, writing (NOT A AND NOT B AND C). The correct application yields NOT (A AND B) AND NOT (NOT C), which simplifies to (NOT A OR NOT B) AND C. Missing the step of negating the inner NOT C produces an extra negation, resulting in an incorrect truth table.
对于表达式NOT ( (A AND B) OR NOT C ),学生可能错误地将外层的非直接赋给每个文字却不改变运算符,写成(NOT A AND NOT B AND C)。正确做法是先得到NOT (A AND B) AND NOT (NOT C),进而化简为(NOT A OR NOT B) AND C。漏掉对内部的NOT C取反这一步会多出一次否定,导致真值表出错。
A disciplined approach: treat the whole expression under the bar as a unit, break the bar at the main operator while flipping it (AND↔OR), then push negations inward. Use brackets generously and verify a few rows of a truth table if time permits. Remember that XOR and equivalence operators also follow specific transformation rules that students sometimes misapply.
规整的方法:将整个杠下表达式视作整体,从主运算符处拆杠并翻转(与变或,或变与),再将否定向内推入。大量使用括号,并在时间允许时验证真值表几行。切记异或及同或运算符也遵循特定的变换规则,学生有时会误用。
6. Pipelining and Data Hazards in Assembly | 汇编中的流水线与数据冒险
Questions about instruction pipelining often ask you to identify data hazards such as read-after-write (RAW) in a given sequence. Students regularly confuse structural hazards with data hazards, or insert NOPs (no-operation instructions) incorrectly because they miscount the number of pipeline stages.
关于指令流水线的题目常要求识别给定序列中的数据冒险,例如写后读。学生经常混淆结构冒险与数据冒险,或因为数错流水线段数而插入错误的NOP(空操作指令)。
In a classic five-stage pipeline (IF, ID, EX, MEM, WB), consider: ADD R1, R2, R3 followed by SUB R4, R1, R5. The SUB needs R1’s value, but ADD writes it back in the WB stage, which occurs after SUB would read it in ID. Stalling by inserting three NOPs (or using forwarding) resolves this. A common error is to insert only one NOP, believing the hazard vanishes after EX.
在经典五级流水线(取指、译码、执行、访存、写回)中,考虑:ADD R1, R2, R3 后跟 SUB R4, R1, R5。SUB需要R1的值,但ADD在WB阶段才写回,在SUB需要在ID阶段读取之后。插入三条NOP(或使用前递)可解决。常见错误是只插入一条NOP,误认为执行阶段后冒险就已消除。
Always draw a timing diagram showing each instruction’s progress through stages cycle by cycle. Mark the point where a value is produced and where it must be consumed; the difference in cycles dictates the stall length. Additionally, note that branch hazards cause control-flow errors, and solving them with branch prediction involves speculative execution which may require flushing if mispredicted.
始终绘制时序图,逐周期展示每条指令进出各阶段。标记产生数值的时刻与必须消费该数值的时刻;周期差值决定了停顿的长度。此外,注意分支冒险导致控制流错误,用分支预测解决涉及推测执行,若预测错误可能需要清空流水线。
7. Big-O Notation and Algorithmic Complexity | 大O表示法与算法复杂度
Students often (mis)state that an algorithm with O(n²) always runs slower than an O(n log n) algorithm. Big-O describes asymptotic behaviour; for small n, constant factors or lower-order terms may dominate. Exams frequently include a table where you must justify which algorithm is preferable given specific input sizes.
学生常(错误地)断言O(n²)算法总比O(n log n)算法运行得慢。大O描述的是渐近行为;对于较小的n,常数因子或低阶项可能占主导。考题经常包含一个表格,要求根据具体输入规模论证哪种算法更优。
Another pitfall: misidentifying the complexity of nested loops. Two nested loops each running n times do yield O(n²), but if the inner loop’s bound depends on the outer counter (for i=1 to n; for j=1 to i), the total work is n(n+1)/2, still O(n²). However, if the inner loop halves the range each iteration or processes a data structure like a binary tree, the complexity could be O(n log n) or O(log n), not O(n²).
另一个易错点:误判嵌套循环的复杂度。各跑n次的两个嵌套循环确实产生O(n²),但若内层循环的界依赖外层计数器(如for i=1 to n; for j=1 to i),总工作量为n(n+1)/2,依然是O(n²)。然而,如果内层循环每次迭代将范围减半,或处理如二叉树的数据结构,复杂度可能为O(n log n)或O(log n),而非O(n²)。
When analysing recursive functions, use recurrence relations. A common mistake is to assume T(n) = 2T(n/2) + O(1) solves to O(n) — it actually yields O(n) by the master theorem, but T(n) = 2T(n/2) + O(n) gives O(n log n). Carefully identify whether the extra work per recursive step is constant or linear, as this changes the result significantly.
分析递归函数时,应使用递推关系。常见错误是假设T(n) = 2T(n/2) + O(1)的解为O(n)——它确实得到O(n)(根据主定理),但T(n) = 2T(n/2) + O(n)的解为O(n log n)。仔细辨别每步递归的额外工作是常数还是线性,这会导致结果显著不同。
8. Two’s Complement and Range of Integers | 补码与整数范围
Given n bits, the range for unsigned integers is 0 to 2ⁿ – 1. For two’s complement signed integers, it is -2ⁿ⁻¹ to 2ⁿ⁻¹ – 1. Students often mistakenly quote the negative bound as -2ⁿ⁻¹ – 1 or confuse the fact that the most negative number has no positive counterpart, causing overflow when negated.
给定n位,无符号整数范围是0到2ⁿ – 1。对于补码有符号整数,范围为-2ⁿ⁻¹到2ⁿ⁻¹ – 1。学生常错误地引用负边界为-2ⁿ⁻¹ – 1,或混淆最负数没有对应正数的事实,导致取负时溢出。
When converting a negative decimal to two’s complement, a reliable method is: write the positive magnitude in binary, pad to n bits, flip all bits (one’s complement), then add 1. Many candidates lose marks by forgetting to pad to the correct width before flipping, or by adding 1 before flipping. The order matters.
将负十进制转为补码时,一个可靠的方法是:写出正值的二进制形式,补足n位,全部位取反(反码),然后加1。许多考生因在取反前忘记补足正确宽度,或在取反前先加1而丢分。顺序很重要。
Example: Represent -9 in 8-bit two’s complement. Positive 9 is 0000 1001. Flip bits to get 1111 0110, then add 1 → 1111 0111. Checking: -128 + 64 + 32 + 16 + 4 + 2 + 1 = -9. If you forget to pad to 8 bits and start with 1001, the flip yields 0110, adding 1 gives 0111, which is 7 — completely wrong. Always expand to the required bit width.
示例:用8位补码表示-9。正数9为0000 1001。位取反得1111 0110,然后加1 → 1111 0111。验证:-128 + 64 + 32 + 16 + 4 + 2 + 1 = -9。如果忘记补足8位而从1001开始,取反得0110,加1得0111即7,完全错误。始终扩展到所需位宽。
9. Inheritance and Polymorphism in Object-Oriented Programming | 面向对象编程中的继承与多态
Exam questions on OOP often provide a base class and a derived class with overridden methods, then ask for the output of a code snippet using polymorphism. The typical blunder is to assume that the method called depends on the declared type of the reference variable rather than the actual object type at runtime.
OOP考题常给出基类和带有重写方法的派生类,然后要求写出一段使用多态的代码的输出。典型的错误是假定调用的方法取决于引用变量的声明类型,而非运行时对象的实际类型。
Consider: Animal a = new Cat(); a.speak(); If speak() is virtual (or dynamically dispatched in languages like Java, which it is by default), Cat’s speak is executed, not Animal’s. A student may incorrectly output the Animal version because they look only at the left-hand side. This misunderstanding reveals a gap in comprehending dynamic binding.
考虑:Animal a = new Cat(); a.speak(); 如果speak()是虚方法(或在Java等语言中默认动态分派),则执行Cat的speak,而非Animal的。学生可能只看了左侧的声明类型而错误地输出Animal版本。这一误解暴露了对动态绑定理解的缺失。
Similarly, when a method is overloaded (same name, different parameters), the resolved method depends on the compile-time type of the reference, not runtime. If Animal has a method eat(Food f) and Cat has eat(Fish f), and you call a.eat(new Food()), the Animal version runs even if a points to a Cat object. Distinguishing between overriding (runtime) and overloading (compile-time) is crucial.
类似地,方法重载(同名不同参数)时,解析的方法取决于引用的编译时类型,而非运行时。若Animal有方法eat(Food f),Cat有eat(Fish f),调用a.eat(new Food())时,即使a指向Cat对象,执行的仍是Animal版本。区分重写(运行时)和重载(编译时)至关重要。
10. The Fetch-Decode-Execute Cycle and Register Transfers | 取指-译码-执行周期与寄存器传送
Describing the fetch-decode-execute cycle seems simple, yet students frequently omit critical detail, such as the role of the Program Counter (PC) incrementing during fetch, or confuse MAR (Memory Address Register) with MDR (Memory Data Register). Marks are allocated for precise wording: “The address in PC is copied to MAR” not “sent to the MDR”.
描述取指-译码-执行周期看似简单,但学生经常遗漏关键细节,比如取指时程序计数器(PC)递增的作用,或混淆MAR(内存地址寄存器)与MDR(内存数据寄存器)。评分标准要求表述精确:“PC中的地址被复制到MAR”,而非“发送到MDR”。
In the decode stage, the instruction in the CIR (Current Instruction Register) is split into opcode and operand. A common error is to say the opcode is sent to the ALU during decode — actually, decode involves the control unit interpreting the opcode. The ALU becomes relevant in the execute stage for arithmetic/logic instructions.
在译码阶段,当前指令寄存器(CIR)中的指令被拆分为操作码和操作数。常见错误是说操作码在译码阶段被送至ALU——实际上,译码涉及控制单元解析操作码。执行阶段ALU才真正参与算术/逻辑指令。
When an exam question asks you to trace the cycle for an ADD instruction with immediate addressing, you must show: the PC contents transferred to MAR, read signal sent, instruction fetched into MDR then copied to CIR, PC incremented, decode, then the immediate operand fetched from the next memory word (requiring another memory read), and finally the operation performed. Sketches of data paths with buses help avoid mistakes.
当考题要求追踪一条立即寻址的ADD指令的周期时,你需要展示:PC内容传送到MAR,发送读信号,指令取入MDR后复制到CIR,PC递增,译码,然后从下一个内存字中取出立即数(需再次读内存),最后执行操作。绘制带总线的数据通路草图有助于避免出错。
11. Normalisation of Floating Point Numbers | 浮点数的规格化
In floating point representation, a normalized mantissa starts with a ‘1’ bit immediately after the sign bit for positive numbers, or ‘0’ for negative numbers in two’s complement representation of the mantissa. A classic error is to say a mantissa is normalized simply because it has a leading 1 somewhere — it must be in the first bit of the mantissa magnitude.
在浮点表示中,规格化的尾数要求首位(紧随符号位后)对于正数为’1’,对于用补码表示的尾数负数则为’0’。典型的错误是仅仅因为某处有个前导1就声称尾数已规格化——1必须出现在尾数幅值的第一个位上。
Example: an unnormalized binary floating point number might have mantissa 0011 0100 with exponent 0100. To normalize, you shift the mantissa left until the bits after the sign bit start with 1 (for positive) or 10 (for negative two’s complement), and decrement the exponent by the number of shifts. Students often shift right instead, or forget to adjust the exponent, losing both bits of precision and range.
示例:一个未规格化的二进制浮点数可能具有尾数0011 0100、指数0100。进行规格化时,你需将尾数左移,直到符号位后方以1开头(正数)或以10开头(补码负数),并将指数减去移位次数。学生常错误地右移,或忘记调整指数,既损失了精度也偏离了范围。
When the mantissa is in two’s complement, the sign bit and the next bit must differ for normalization (01 for positive, 10 for negative). If a positive mantissa begins with 00, you left-shift and decrement the exponent; if it begins with 11 (negative) you do the same, until the 01 or 10 pattern is achieved. Misapplying this to signed magnitude representation instead of two’s complement leads to incorrect exam answers.
当尾数以补码表示时,符号位与下一位必须不同才算规格化(正数为01,负数为10)。若正数尾数以00开始,则左移并自减指数;若以11开始(负数),同样处理,直到达到01或10模式。若将此规则误用于原码表示而非补码,就会导致考试答案错误。
12. Ethical and Legal Implications of Technology | 技术涉及的伦理与法律问题
Essay-style questions on computing ethics require more than vague statements. To score high marks, you must apply named principles (e.g., the Data Protection Act, Computer Misuse Act, GDPR, net neutrality, digital divide) to a given scenario, discussing stakeholders and consequences. A common mistake is merely listing laws without linking them to the specific context.
关于计算机伦理的论述题需要的不只是笼统表述。要得高分,必须将命名的原则(如《数据保护法》《计算机滥用法》、GDPR、网络中立性、数字鸿沟)应用到给定情景中,讨论利益相关方和后果。常见错误是仅罗列法律而未与具体上下文关联。
For a question on big data analytics in healthcare, candidates might write ‘It must follow GDPR’ but fail to mention consent, data minimization, right to erasure, and the tension between public health benefits and individual privacy. The examiner wants to see reasoning about how the law’s provisions apply to the collection, storage, and sharing of sensitive health records.
对医疗保健中大数据分析的题目,考生可能会写“必须遵守GDPR”,但未提及同意、数据最小化、删除权,以及公共健康利益与个人隐私之间的张力。考官希望看到的是法律条款如何应用于敏感健康记录的收集、存储与共享的推理论证。
Similarly, discussing encryption backdoors requires balancing national security against user privacy, referencing laws like the Investigatory Powers Act. Always take a balanced view: argue for and against, but end with a justified conclusion. Avoid extreme statements unsupported by evidence, and remember to mention the ethical frameworks (utilitarianism, deontology) that underpin your reasoning.
类似地,讨论加密后门时需要平衡国家安全与用户隐私,引用如《调查权力法》等法律。始终采取平衡视角:正反两面论证,但以有理有据的结论收尾。避免无证据支持的极端表述,并记得提及支撑论证的伦理框架(功利主义、义务论)。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导