IB & AQA Computer Science: Typical Exam Questions Explained | IB 与 AQA 计算机科学典型例题详解

📚 IB & AQA Computer Science: Typical Exam Questions Explained | IB 与 AQA 计算机科学典型例题详解

In both IB and AQA Computer Science, a solid grasp of core concepts is best built through worked examples. This article takes you through ten typical exam-style problems, from binary conversion and Boolean simplification to recursion and ethical scenarios. Each solution is broken down step by step, pairing English and Chinese explanations so you can reinforce your understanding no matter which language you study in.

无论是 IB 还是 AQA 计算机科学课程,扎实掌握核心概念的最佳途径就是通过典型例题的训练。本文精选十道考试风格的题目,涵盖二进制转换、布尔代数化简、递归和职业道德情境等主题。每道题的解答都分步拆解,并采用中英双语对照讲解,帮助你在两种语言环境中巩固理解。

1. Binary to Hexadecimal Conversion | 二进制转十六进制

Problem: Convert the binary number 10111101 to hexadecimal. Show your working.

题目:将二进制数 10111101 转换为十六进制,并写出步骤。

Step 1 – Group the binary digits into nibbles (4‑bit groups) starting from the right. Pad the leftmost group with leading zeros if necessary. For 10111101, the groups are 1011 and 1101.

步骤一:从右向左将二进制位每 4 位分为一组(一个 nibble)。如果最左边不足 4 位则补前导零。对 10111101,分组为 10111101

Step 2 – Convert each nibble to its decimal equivalent and then to hexadecimal. 1011 binary = 8+2+1 = 11 (decimal) = B (hex). 1101 binary = 8+4+1 = 13 = D (hex).

步骤二:将每个 nibble 先转为十进制,再转为十六进制。1011₂ = 8+2+1 = 11₁₀ = B₁₆;1101₂ = 8+4+1 = 13₁₀ = D₁₆。

Step 3 – Write the hex digits in the same order. The answer is BD.

步骤三:按原有顺序写出十六进制数码,结果为 BD


2. Boolean Absorption Law | 布尔吸收律化简

Problem: Simplify the Boolean expression: A AND (A OR B).

题目:化简布尔表达式:A AND (A OR B)

Step 1 – Recognise the pattern. The expression matches the absorption law: A · (A + B) = A. (Here · is AND, + is OR.)

步骤一:识别模式。该表达式符合吸收律:A · (A + B) = A(其中 · 表示 AND,+ 表示 OR)。

Step 2 – Verify with a truth table if needed. For A=0, the whole expression is 0·(0+B)=0. For A=1, it is 1·(1+B)=1·1=1. The output always equals A.

步骤二:必要时可用真值表验证。当 A=0 时,0·(0+B)=0;当 A=1 时,1·(1+B)=1·1=1。输出恒等于 A。

Therefore, the simplified expression is simply A.

因此,化简后的表达式就是 A


3. Tracing an Algorithm | 算法追踪

Problem: Trace the following pseudocode and state the final value of sum.

sum ← 0
FOR i ← 1 TO 5
    sum ← sum + i * i
NEXT i
OUTPUT sum

题目:追踪以下伪代码,写出变量 sum 的最终值。

Step 1 – Initialise sum to 0. The loop variable i takes values 1, 2, 3, 4, 5.

步骤一:sum 初始化为 0。循环变量 i 依次取 1、2、3、4、5。

Step 2 – Build a trace table: i=1 → sum=0+1=1; i=2 → sum=1+4=5; i=3 → sum=5+9=14; i=4 → sum=14+16=30; i=5 → sum=30+25=55.

步骤二:建立追踪表:i=1 → sum=0+1=1;i=2 → sum=1+4=5;i=3 → sum=5+9=14;i=4 → sum=14+16=30;i=5 → sum=30+25=55。

Step 3 – After the loop, sum holds 55. The output is 55.

步骤三:循环结束后 sum 为 55。输出结果为 55


4. Stack Operations | 栈操作

Problem: An empty stack undergoes the following operations: push(5), push(8), pop(), push(2), push(9), pop(). Show the stack contents after each operation (top is on the right).

题目:对一个空栈依次执行以下操作:push(5)、push(8)、pop()、push(2)、push(9)、pop()。请画出每一步执行后的栈内容(规定右端为栈顶)。

Operation / 操作 Stack (bottom → top) / 栈(底→顶)
Start / 初始 [ ]
push(5) [5]
push(8) [5, 8]
pop() [5] (8 removed / 8 被弹出)
push(2) [5, 2]
push(9) [5, 2, 9]
pop() [5, 2] (9 removed / 9 被弹出)

Final stack is [5, 2]. This illustrates LIFO behaviour.

最终栈内容为 [5, 2],体现了后进先出(LIFO)的特性。


5. Subnetting and Host Capacity | 子网划分与主机容量

Problem: Given the network address 192.168.1.0/26, determine the subnet mask in dotted decimal and the maximum number of usable host addresses.

题目:给定网络地址 192.168.1.0/26,写出点分十进制表示的子网掩码,并计算最大可用主机地址数。

Step 1 – The /26 prefix means the first 26 bits are network bits. The subnet mask has 26 ones followed by 6 zeros. In binary: 11111111.11111111.11111111.11000000.

步骤一:/26 表示前 26 位为网络位。子网掩码由 26 个 1 和 6 个 0 构成。二进制为:11111111.11111111.11111111.11000000。

Step 2 – Convert to decimal: 255.255.255.192.

步骤二:点分十进制转换:255.255.255.192。

Step 3 – The host portion has 6 bits. Total addresses per subnet = 2⁶ = 64. Subtract the network address and broadcast address to get usable hosts: 64 – 2 = 62.

步骤三:主机部分有 6 位,每个子网地址总数为 2⁶ = 64。减去网络地址和广播地址得到可用主机数:64 – 2 = 62


6. SQL Query with JOIN | 带连接查询的 SQL 语句

Problem: Two tables are given – Students(id, name) and Enrolments(student_id, course). Write an SQL query that lists the names of all students enrolled in the course ‘Computer Science’.

题目:设有两张表:Students(id, name)Enrolments(student_id, course)。请写出 SQL 查询,列出所有选修了 ‘Computer Science’ 课程的学生姓名。

Step 1 – Identify the linking attribute: Students.id matches Enrolments.student_id.

步骤一:确定连接属性:Students.idEnrolments.student_id 对应。

Step 2 – Use an INNER JOIN to combine rows where the keys match. Filter with a WHERE clause for the course name.

步骤二:使用 INNER JOIN 将键值匹配的行合并,并用 WHERE 子句筛选课程名称。

Query: SELECT Students.name FROM Students INNER JOIN Enrolments ON Students.id = Enrolments.student_id WHERE Enrolments.course = 'Computer Science';

查询语句:SELECT Students.name FROM Students INNER JOIN Enrolments ON Students.id = Enrolments.student_id WHERE Enrolments.course = 'Computer Science';

Alternative: using implicit join with WHERE condition on two tables.

也可以用隐式内连接:SELECT Students.name FROM Students, Enrolments WHERE Students.id = Enrolments.student_id AND Enrolments.course = 'Computer Science';


7. Recursive Factorial Trace | 递归阶乘追踪

Problem: Consider the recursive function factorial(n) defined as: if n=0 return 1, else return n × factorial(n−1). Trace the call factorial(4) and show the return values.

题目:给定递归函数 factorial(n):若 n=0 返回 1,否则返回 n × factorial(n−1)。追踪调用 factorial(4) 的过程并写出各层返回值。

Step 1 – Build the call stack: factorial(4) calls factorial(3), which calls factorial(2), then factorial(1), then factorial(0).

步骤一:建立调用栈:factorial(4) 调用 factorial(3),后者调用 factorial(2),再调用 factorial(1),最终调用 factorial(0)。

Step 2 – Base case: factorial(0) returns 1. Then unwind: factorial(1) = 1×1 = 1, factorial(2) = 2×1 = 2, factorial(3) = 3×2 = 6, factorial(4) = 4×6 = 24.

步骤二:基准情形 factorial(0) 返回 1。然后逐层返回:factorial(1)=1×1=1,factorial(2)=2×1=2,factorial(3)=3×2=6,factorial(4)=4×6=24。

The result of factorial(4) is 24.

factorial(4) 的结果为 24


8. Two’s Complement Representation | 二进制补码表示

Problem: Using 8‑bit two’s complement, represent the decimal value -6. Show your working steps.

题目:用 8 位二进制补码表示十进制数 -6,并写出计算步骤。

Step 1 – Write the magnitude in 8‑bit binary: +6 = 00000110.

步骤一:写出绝对值的 8 位二进制:+6 = 00000110。

Step 2 – Invert all bits (one’s complement): 11111001.

步骤二:将所有位取反(得到反码):11111001。

Step 3 – Add 1 to the least significant bit: 11111001 + 1 = 11111010. This is the two’s complement representation.

步骤三:在最低位加 1:11111001 + 1 = 11111010,即为补码表示。

Check: 11111010 as unsigned = 250, but in 8‑bit two’s complement, -6 has an alternative value of 2⁸ – 6 = 250, which matches. Thus, -6 = 11111010.

验证:11111010 当作无符号数是 250,而在 8 位补码中 -6 = 2⁸ – 6 = 250,结果吻合。因此 -6 = 11111010


9. Binary Search Tree In‑order Traversal | 二叉搜索树的中序遍历

Problem: Given a BST with root 8, left child 3 (further left 1, right 6), and right child 10 (no left child, right 14). Perform an in‑order traversal and list the nodes in the order visited.

题目:给定一棵二叉搜索树,根为 8,左子 3(其左子 1,右子 6),右子 10(无左子,右子 14)。请执行中序遍历,并列出访问结点的顺序。

Step 1 – Recursively traverse the left subtree of 8. The root of left subtree is 3: go to its left child 1 (no children) → visit 1, then visit 3, then traverse right of 3: visit 6.

步骤一:递归遍历 8 的左子树。左子树根为 3:访问其左子 1(无孩子)→ 输出 1,然后访问 3,再遍历 3 的右子:输出 6。

Step 2 – Visit the root 8.

步骤二:访问根结点 8。

Step 3 – Traverse the right subtree of 8: root 10 has no left child, so visit 10, then its right child 14.

步骤三:遍历 8 的右子树:根 10 无左子,访问 10,然后访问其右子 14。

The in‑order sequence is 1, 3, 6, 8, 10, 14, which is sorted because it is a BST.

中序遍历序列为 1, 3, 6, 8, 10, 14,由于是二叉搜索树,结果呈升序排列。


10. Ethical Scenario – Data Collection without Consent | 职业道德情境 – 未经同意的数据收集

Problem: A software company develops a mobile app that collects users’ location data even when the app is closed, without clearly informing users or obtaining explicit consent. Discuss the ethical issues using principles from the ACM or BCS code of conduct.

题目:某软件公司开发了一款移动应用,该应用会在关闭时仍收集用户位置数据,且未明确告知用户或取得明确同意。请结合 ACM 或 BCS 职业道德规范,讨论其中的伦理问题。

Step 1 – Identify the relevant principles: ‘Respect privacy’, ‘Be honest and trustworthy’, and ‘Avoid harm’. The company violates the principle of informed consent by not transparently explaining what data is collected and why.

步骤一:识别相关原则:“尊重隐私”、“诚实守信”和“避免造成伤害”。该公司未透明地说明收集哪些数据及其用途,违背了知情同意原则。

Step 2 – The lack of clear opt‑in mechanism means users are not given genuine control over their personal information. This conflicts with data protection regulations such as GDPR and the spirit of professional integrity.

步骤二:缺少明确的主动同意机制,用户无法真正控制自己的个人信息,这与 GDPR 等数据保护法规以及职业操守精神相冲突。

Step 3 – Possible harms: erosion of user trust, potential misuse of sensitive data by third parties, and legal consequences for the company. Ethical practice would require a prominent consent screen, data minimisation, and an option to delete collected data.

步骤三:可能带来的危害:用户信任度下降、敏感数据可能被第三方滥用、以及企业面临法律风险。符合伦理的做法应包括显著的同意界面、数据最小化原则,以及允许用户删除已收集的数据。

In summary, the scenario breaches core computing ethics tenets of accountability, transparency, and respect for individuals.

总之,这一情境违背了计算机职业道德中的问责、透明和尊重个人权利等基本信条。


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