← 返回资讯屏轩教育 · 行业资讯

A-Level WJEC Computer Science: Worked Examples | A-Level WJEC 计算机:典型例题详解

2026-07-14 07:21 · 本文部分内容由AI辅助创作

📚 A-Level WJEC Computer Science: Worked Examples | A-Level WJEC 计算机:典型例题详解

This article presents a selection of typical worked examples from the WJEC A-Level Computer Science specification. Each example is designed to reinforce core concepts such as Boolean algebra, data structures, algorithms, processor architecture, and networking. The step-by-step solutions help students master the problem-solving skills required for the examination.

本文精选了 WJEC A-Level 计算机科学考试中的典型例题。每道题旨在巩固布尔代数、数据结构、算法、处理器体系结构和网络等核心概念。逐步讲解的解题方法有助于学生掌握考试所需的解题技能。

1. Boolean Algebra Simplification | 布尔代数化简

Simplify the Boolean expression F = A·B + A·B' using the laws of Boolean algebra.

利用布尔代数定律化简表达式 F = A·B + A·B'。

Step 1: Write the original expression.
2: Notice that A is common to both terms; apply the distributive law in reverse: A·B + A·B' = A·(B + B').
Step 3: Apply the complement law (B + B' = 1).
Step 4: Apply the identity law (A·1 = A).
Thus, F = A.

步骤1:写出原始表达式。
步骤2:发现两项都有公因子 A,反向利用分配律:A·B + A·B' = A·(B + B')。
步骤3:应用互补律 (B + B' = 1)。
步骤4:应用恒等律 (A·1 = A)。
因此,F = A。

This simplification is extremely common in circuit design and logic minimisation. The result shows that the output F depends only on A, regardless of B.

这种化简在电路设计和逻辑最小化中非常常见。结果表明输出 F 只取决于 A,与 B 无关。


2. Karnaugh Map Minimisation | 卡诺图化简

Use a Karnaugh map to minimise the expression F(A,B,C) = Σ(1,3,4,5,7).

使用卡诺图化简表达式 F(A,B,C) = Σ(1,3,4,5,7)。

1). Group the ones into the largest possible power-of-two blocks. We can form one group of four (minterms 1,3,5,7) covering A'·C + A·C = C, and one group of two (minterms 4,5) which gives A·B'. Thus the minimised expression is F = C + A·B'.

画出三变量卡诺图,行表示 A (0,1),列表示 BC (00,01,11,10)。在最小项位置 1 (001)、3 (011)、4 (100)、5 (101)、7 (111) 填入 1。将 1 组合成尽可能大的 2 的幂次块。可以形成一个四格组 (最小项 1,3,5,7) 覆盖 A'·C + A·C = C,以及一个两格组 (最小项 4,5) 给出 A·B'。因此最简表达式为 F = C + A·B'。

Verify the result with a truth table to ensure the original minterms are all covered and no additional terms are generated.

用真值表验证结果,确保所有原始最小项都被覆盖,且没有产生额外项。


3. Binary Addition and Overflow Detection | 二进制加法与溢出检测

Perform the 8-bit two's complement addition of 01011010 (+90) and 01100111 (+103) and determine whether an overflow occurs.

对 8 位二进制补码进行加法运算:01011010 (+90) 和 01100111 (+103),并判断是否发生溢出。

Write the numbers:
01011010
+ 01100111
-----------
Carry bits: 11111000 (from right)
Sum: 11000001

写出两个数:
01011010
+ 01100111
-----------
进位:11111000(从低位向高位)
和:11000001

In two' This is clear overflow because the sum of two positive numbers cannot be negative. Overflow occurs when the carry into the sign bit differs from the carry out of the sign bit. Here, carry into bit 7 is 1, carry out of bit 7 is 0, so overflow flag is set.

在8位二进制补码中,数值范围是 -128 到 +127。两个操作数均为正数(最高位为0),但和的最高位为1,表示结果为负数。两个正数相加不可能得到负数,因此发生了溢出。当进入符号位的进位与符号位产生的进位不同时,溢出发生。这里进入第7位的进位为1,从第7位出来的进位为0,因此溢出标志置位。


4. Bubble Sort Algorithm Trace | 冒泡排序算法跟踪

Apply the bubble sort algorithm to the array [5, 1, 4, 2, 8] and show the state after each pass.

对数组 [5, 1, 4, 2, 8] 应用冒泡排序算法,并显示每趟之后的状态。

Pass 1: Compare and swap adjacent pairs if out of order.
ap → [1,4,5,2,8]; (5,2) → swap → [1,4,2,5,8]; (5,8) → no swap. End of pass 1: [1,4,2,5,8].
: (1,4) no swap; (4,2) swap → [1,2,4,5,8]; (4,5) no swap; (5,8) no swap. End: [1,2,4,5,8].
Pass 3: no swaps occur, indicating the array is sorted. Bubble sort will perform one final check pass and terminate.

第一趟:比较并交换逆序的相邻元素。
(5,1) 交换 → [1,5,4,2,8];(5,4) 交换 → [1,4,5,2,8];(5,2) 交换 → [1,4,2,5,8];(5,8) 不交换。第一趟结束:[1,4,2,5,8]。
第二趟:(1,4) 不交换;(4,2) 交换 → [1,2,4,5,8];(4,5) 不交换;(5,8) 不交换。结束:[1,2,4,5,8]。
第三趟:没有发生交换,表明数组已有序。冒泡排序会再执行一趟确认,然后终止。

The time complexity is O(n²) in the worst case. Students should be able to write pseudocode for bubble sort and trace it on a given data set.

最坏情况下的时间复杂度为 O(n²)。学生应能写出冒泡排序的伪代码,并在给定数据集上进行跟踪。


5. Stack Operations with Push and Pop | 栈的压入与弹出操作

An empty stack has a maximum size of 5. Perform the following sequence: push(7), push(3), pop(), push(9), push(1), pop(), push(5), pop(), pop(). Show the stack contents and top pointer after each operation.

一个空栈的最大容量为5。执行以下序列:push(7), push(3), pop(), push(9), push(1), pop(), push(5), pop(), pop()。显示每次操作后的栈内容和栈顶指针。

Start: Stack = [], top = -1.
push(7): Stack = [7], top = 0.
push(3): [7,3], top=1.
pop(): removes 3, Stack = [7], top=0.
push(9): [7,9], top=1.
push(1): [7,9,1], top=2.
pop(): removes 1, [7,9], top=1.
push(5): [7,9,5], top=2.
pop(): removes 5, [7,9], top=1.
pop(): removes 9, [7], top=0.

初始:栈 = [],栈顶指针 top = -1。
push(7):栈 = [7], top=0。
push(3):[7,3], top=1。
pop():弹出 3,栈 = [7], top=0。
push(9):[7,9], top=1。
push(1):[7,9,1], top=2。
pop():弹出 1,[7,9], top=1。
push(5):[7,9,5], top=2。
pop():弹出 5,[7,9], top=1。
pop():弹出 9,[7], top=0。

Stacks are LIFO structures. Checking for underflow (pop from empty) and overflow (push when full) is crucial; here no error occurs as operations remain within limits.

栈是后进先出(LIFO)结构。检查下溢(空栈弹出)和上溢(满栈压入)至关重要;在此序列中,所有操作均在限制内,没有错误发生。


6. Pseudocode Trace Table for Loop | 循环伪代码跟踪表

Consider the following pseudocode:

   total ← 0
   FOR i ← 1 TO 4
      total ← total + i * i
   ENDFOR
   OUTPUT total

Construct a trace table showing the values of i and total at each iteration.

考虑以下伪代码:

   total ← 0
   FOR i ← 1 TO 4
      total ← total + i * i
   ENDFOR
   OUTPUT total

建立一个跟踪表,显示每次迭代中 i 和 total 的值。

Iterationitotal (before update)total (after update)
Initial-00
1101
2215
33514
441430

Final output is 30. Trace tables help visualise variable changes and are essential for debugging algorithms.

最终输出为 30。跟踪表有助于可视化变量变化,是调试算法的重要工具。


广告 / Sponsored

7. Logic Gate Circuit and Truth Table | 逻辑门电路与真值表

Draw a logic circuit for F = (A AND B) OR (NOT C) and produce its truth table.

画出 F = (A AND B) OR (NOT C) 的逻辑电路图,并列出真值表。

The circuit consists of an AND gate with inputs A and B, a NOT gate on input C, and an OR gate combining the AND output and the NOT output. Truth table:

ABCA AND BNOT CF
000011
001000
010011
011000
100011
101000
110111
111101

The truth table confirms that F is 1 when C is 0 or when both A and B are 1. This is a typical exam question requiring clear gate representation and systematic truth table construction.

真值表确认当 C 为 0 或 A 与 B 同时为 1 时,F 为 1。这是典型的考题,要求清晰的门电路表示和系统化的真值表构建。


8. Fetch-Decode-Execute Cycle Steps | 取指-译码-执行周期步骤

Describe the steps involved in the fetch-decode-execute (FDE) cycle and explain the role of registers such as PC, MAR, MDR, and CIR.

描述取指-译码-执行(FDE)周期的步骤,并解释 PC、MAR、MDR 和 CIR 等寄存器的作用。

Fetch: The Program Counter (PC) holds the address of the next instruction. This address is copied to the Memory Address Register (MAR) and the PC is incremented. A read signal is sent to memory, and the instruction from that address is placed into the Memory Data Register (MDR), then transferred to the Current Instruction Register (CIR).
Decode: The control unit decodes the instruction in the CIR to determine the operation and operands.
Execute: The control unit activates the appropriate parts of the CPU (ALU, registers, buses) to carry out the instruction. The cycle repeats.

取指:程序计数器(PC)存放下一条指令的地址。该地址被复制到内存地址寄存器(MAR),然后 PC 递增。向内存发出读信号,该地址处的指令被放入内存数据寄存器(MDR),然后传送到当前指令寄存器(CIR)。
译码:控制单元对 CIR 中的指令进行译码,确定操作码和操作数。
执行:控制单元激活 CPU 的相应部件(ALU、寄存器、总线)来执行指令。此周期不断重复。

This cycle is fundamental to the Von Neumann architecture and is frequently examined through diagrams and register descriptions.

这个周期是冯·诺依曼体系结构的基础,常用于图表和寄存器描述的考察中。


9. Network Protocol Stack (TCP/IP) | 网络协议栈 (TCP/IP)

Explain how the TCP/IP model layers interact when sending an email, referencing the specific protocols used at each layer.

解释发送电子邮件时 TCP/IP 模型各层如何交互,并指出每层使用的具体协议。

Application layer: The email client uses SMTP to format the message and pass it to the transport layer.
Transport layer: TCP segments the data, adds a header with sequence numbers, and establishes a reliable connection.
Internet layer: IP adds source and destination IP addresses, encapsulating the TCP segment into packets.
Network Access layer: Frames the packet with MAC addresses for the local network and transmits it as bits over the physical medium.
At the receiving end, the layers are traversed in reverse, with Ethernet, IP, TCP, and SMTP processing the incoming data.

应用层:电子邮件客户端使用 SMTP 格式化邮件,并将其传递给传输层。
传输层:TCP 将数据分段,添加包含序列号的报头,并建立可靠连接。
网络层:IP 添加源和目的 IP 地址,将 TCP 报文段封装成数据包。
网络接入层:将数据包装帧,加上本地网络的 MAC 地址,作为比特流在物理介质上传输。
在接收端,各层以相反顺序处理,由以太网、IP、TCP 和 SMTP 处理传入数据。

Understanding the encapsulation process and the role of each layer is essential for network-related exam questions.

理解封装过程和每一层的作用对于解答网络相关考题至关重要。


10. Assembly Language Addressing Modes | 汇编语言寻址模式

Identify the addressing modes used in the following assembly instructions for a simple processor:
LOAD #5 (immediate) ; STORE 200 (direct) ; ADD (R1) (indirect).

识别下列简单处理器汇编指令中使用的寻址模式:
LOAD #5(立即寻址);STORE 200(直接寻址);ADD (R1)(间接寻址)。

In LOAD #5, the operand #5 is a literal value that is loaded directly into the accumulator. This is immediate addressing.
In STORE 200, the address 200 is given directly in the instruction; the contents of the accumulator are stored into memory location 200. This is direct/absolute addressing.
In ADD (R1), the parentheses indicate indirect addressing: the register R1 holds the memory address of the operand to be added. The CPU first reads the address from R1, then accesses memory at that address to get the data.

在 LOAD #5 中,操作数 #5 是一个直接加载到累加器的文字值,这属于立即寻址。
在 STORE 200 中,地址 200 被直接写在指令里;累加器的内容存入内存地址 200,这是直接/绝对寻址。
在 ADD (R1) 中,括号表示间接寻址:寄存器 R1 保存着操作数的内存地址。CPU 首先从 R1 读取地址,然后访问该地址的内存以获取数据。

Addressing modes are a core part of processor architecture; exam questions often ask students to trace assembly programs and identify which mode is being used.

寻址模式是处理器体系结构的重要组成部分;考试经常要求学生跟踪汇编程序并识别使用的寻址模式。


11. Recursive Algorithm: Factorial | 递归算法:阶乘

Write pseudocode for a recursive function to compute n! and trace the execution for factorial(4).

编写计算 n! 的递归函数伪代码,并跟踪 factorial(4) 的执行过程。

Pseudocode:

FUNCTION factorial(n)
   IF n = 0 THEN
      RETURN 1
   ELSE
      RETURN n * factorial(n - 1)
   ENDIF
ENDFUNCTION

Trace for factorial(4):
factorial(4) = 4 * factorial(3)
factorial(3) = 3 * factorial(2)
factorial(2) = 2 * factorial(1)
factorial(1) = 1 * factorial(0)
factorial(0) = 1
ial(1) = 1*1 = 1; factorial(2) = 2*1 = 2; factorial(3) = 3*2 = 6; factorial(4) = 4*6 = 24.

伪代码:

FUNCTION factorial(n)
   IF n = 0 THEN
      RETURN 1
   ELSE
      RETURN n * factorial(n - 1)
   ENDIF
ENDFUNCTION

跟踪 factorial(4):
factorial(4) = 4 * factorial(3)
factorial(3) = 3 * factorial(2)
factorial(2) = 2 * factorial(1)
factorial(1) = 1 * factorial(0)
factorial(0) = 1
展开返回:factorial(1) = 1*1 = 1;factorial(2) = 2*1 = 2;factorial(3) = 3*2 = 6;factorial(4) = 4*6 = 24。

Recursion uses a call stack; each call suspends the previous one until the base case is reached. The base case must be correctly specified to avoid infinite recursion.

递归使用调用栈;每次调用会挂起前一个调用,直到抵达基线条件。必须正确指定基线条件,避免无限递归。


12. Database SQL Query | 数据库 SQL 查询

Given a table Students ite an SQL query to retrieve the names of students with Grade ≥ 80, sorted alphabetically.

给定一个表 Students,包含字段 ID、Name、Grade,编写 SQL 查询,检索 Grade ≥ 80 的学生姓名,并按字母顺序排序。

SQL: SELECT Name FROM Students WHERE Grade >= 80 ORDER BY Name ASC;

SQL语句:SELECT Name FROM Students WHERE Grade >= 80 ORDER BY Name ASC;

This type of query is standard for data manipulation. Exam questions may also involve JOINs or aggregate functions such as COUNT, AVG, SUM.

这种查询是数据操作的标准题型。考试题目还可能涉及 JOIN 以及 COUNT、AVG、SUM 等聚合函数。

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

广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

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

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao