📚 GCSE Edexcel Computer Science: Typical Exam Questions Explained | GCSE Edexcel 计算机:典型例题详解
Welcome to this revision guide covering ten typical exam-style questions for the GCSE Edexcel Computer Science specification. Each section presents a question, followed by a step-by-step solution and commentary, helping you master key topics from binary arithmetic to network security. Use these worked examples to test your understanding and improve your exam technique.
欢迎阅读本复习指南,涵盖 GCSE Edexcel 计算机科学考试中十道典型例题。每个小节都提供一道题目,随后给出逐步解答和评注,帮助你掌握从二进制算术到网络安全的关键知识点。通过这些范例来自测理解、提升应试技巧。
1. Binary Arithmetic & Logical Shifts | 二进制算术与逻辑移位
Question: Add the two 8-bit binary numbers 00101101 and 01011010. Give your answer as an 8-bit binary number and state whether an overflow occurred. Then perform a logical left shift of 2 places on the binary number 00010111 and explain the effect on its denary value.
问题:将两个8位二进制数 00101101 和 01011010 相加。结果以8位二进制数给出,并说明是否发生溢出。然后对二进制数 00010111 执行2位逻辑左移,解释对其十进制值的影响。
Solution – Addition: Write the numbers with column alignment. Starting from the least significant bit (rightmost): 1+0 = 1; 0+1 = 1; 1+0 = 1; 1+1 = 0 carry 1; 0+1+carry = 0 carry 1; 1+0+carry = 0 carry 1; 0+1+carry = 0 carry 1; 0+0+carry = 1. The result is 10000111. Since we added two positive numbers and the MSB of the result is 1 (which indicates a negative in two’s complement), but in unsigned interpretation, 10000111 = 135, and 00101101 (45) + 01011010 (90) = 135. There is no overflow because the result fits in 8 bits (max 255). However, in a signed context, overflow would be checked by carries into and out of the MSB; here carry in is 1, carry out is 0, so signed overflow exists. The question does not specify signed, so we state that for unsigned numbers, no overflow occurs.
解答——加法:写出列对齐的数字。从最低位(最右)开始:1+0=1;0+1=1;1+0=1;1+1=0 进位1;0+1+进位=0 进位1;1+0+进位=0 进位1;0+1+进位=0 进位1;0+0+进位=1。结果为 10000111。两个正数相加,结果的最高有效位为1(在补码中表示负数),但若按无符号数解释,10000111 = 135,且 00101101 (45) + 01011010 (90) = 135。没有溢出,因为结果在8位范围内(最大255)。若按带符号数,需检查进入和离开MSB的进位:进位入为1,进位出为0,因此带符号溢出存在。题目未指明带符号,故说明对于无符号数无溢出。
Solution – Logical shift: Original 00010111 = 23 in denary. After logical left shift 2 places: shift each bit two positions left, discarding the leftmost two bits, and fill the rightmost bits with zeros. Result: 01011100 = 92. Left shifting by 2 multiplies the original number by 22 = 4, unless bits ‘1’ are lost. 23 x 4 = 92, so the shift effectively multiplied by 4.
解答——逻辑移位:原数 00010111 = 23(十进制)。逻辑左移2位后:所有位向左移动两位,丢弃最左两位,最右两位补0。结果:01011100 = 92。左移2位相当于将原数乘以 22 = 4,前提是没有丢失值为1的位。23 × 4 = 92,因此移位实现了乘以4的效果。
2. Logic Gates & Truth Tables | 逻辑门与真值表
Question: Draw the logic circuit for the expression Q = (A AND B) OR (NOT C). Then produce the truth table for all possible combinations of inputs A, B and C.
问题:画出表达式 Q = (A AND B) OR (NOT C) 的逻辑电路,并为输入 A、B、C 的所有可能组合制作真值表。
Solution – Circuit diagram: The circuit consists of one AND gate with inputs A and B, and a NOT gate with input C. The outputs of these two gates are fed into an OR gate, whose output is Q. In an exam sketch, you would draw standard symbols and connect them accordingly.
解答——电路图:电路包含一个与门,输入为 A 和 B;一个非门,输入为 C。这两个门的输出作为或门的输入,或门的输出为 Q。在考试草图中,需要画出标准符号并正确连线。
Solution – Truth table: We evaluate all 23 = 8 combinations.
解答——真值表:计算所有 23 = 8 种组合。
| A | B | C | A AND B | NOT C | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
Notice that Q is 0 only when (A AND B) is 0 and C is 1 simultaneously; in all other cases Q = 1. This matches the OR behaviour.
注意,Q 只在 (A AND B) 为 0 且 C 为 1 时等于 0;其他所有情况 Q = 1。这与或运算一致。
3. Pseudocode Trace & Debug | 伪代码追踪与排错
Question: Study the following pseudocode and determine the final value of total and the output. Identify any logical error if the intention was to sum the first five square numbers.
total ← 0
FOR i ← 1 TO 5
total ← total + i * i
ENDFOR
OUTPUT total
问题:分析以下伪代码,确定变量 total 的最终值和输出内容。如果原意是对前五个平方数求和,找出其中任何逻辑错误。
Solution – Trace: i=1: total = 0+1 = 1; i=2: total = 1+4 = 5; i=3: total = 5+9 = 14; i=4: total = 14+16 = 30; i=5: total = 30+25 = 55. Output is 55. The code correctly sums squares of integers 1 to 5. There is no logical error; it achieves exactly what it states.
解答——追踪:i=1: total = 0+1 = 1; i=2: total = 1+4 = 5; i=3: total = 5+9 = 14; i=4: total = 14+16 = 30; i=5: total = 30+25 = 55。输出为 55。代码正确地对整数 1 到 5 的平方求和,不存在逻辑错误。
However, a common exam twist would be if the loop were written as FOR i ← 0 TO 4 or total ← total + i – always trace carefully. Here the algorithm is flawless.
然而,考试中常见的变形是循环写成 FOR i ← 0 TO 4 或 total ← total + i——务必仔细追踪。这里算法没有问题。
4. Bubble Sort Algorithm | 冒泡排序算法
Question: The array [6, 2, 9, 4, 3] is to be sorted into ascending order using bubble sort. Show the state of the array after the first complete pass. How many passes are required in total to guarantee the array is sorted?
问题:数组 [6, 2, 9, 4, 3] 要使用冒泡排序按升序排列。给出经过第一趟完整冒泡后数组的状态。总共至少需要多少趟才能保证数组有序?
Solution – First pass: Compare 6 and 2 → swap → [2,6,9,4,3]; compare 6 and 9 → no swap; compare 9 and 4 → swap → [2,6,4,9,3]; compare 9 and 3 → swap → [2,6,4,3,9]. End of first pass: [2,6,4,3,9]. The largest element, 9, is now in its final position.
解答——第一趟:比较 6 和 2 → 交换 → [2,6,9,4,3];比较 6 和 9 → 不交换;比较 9 和 4 → 交换 → [2,6,4,9,3];比较 9 和 3 → 交换 → [2,6,4,3,9]。第一趟结束:[2,6,4,3,9]。最大元素 9 已经到达最终位置。
Solution – Number of passes: For n=5 elements, bubble sort needs at most n–1 = 4 passes to guarantee a sorted order. After each pass, the next largest element bubbles to its correct position. In this specific case, after pass 2 we might obtain [2,4,3,6,9]; pass 3 gives [2,3,4,6,9], which is sorted. A fourth pass is performed to verify no swaps occur. So at least 4 passes in a standard algorithm.
解答——趟数:对于 n=5 个元素,冒泡排序最多需要 n–1 = 4 趟以确保有序。每一趟结束后下一个最大元素会“冒泡”到正确位置。在这个例子中,第二趟后可能得到 [2,4,3,6,9];第三趟后 [2,3,4,6,9] 已排序。标准算法会执行第四趟以确认无需交换。因此至少需要 4 趟。
5. Network Protocols & Layers | 网络协议与分层
Question: Explain the function of the TCP/IP model’s four layers. Using an example, describe the role of the Transport layer and the Internet layer in sending a web page request.
问题:解释 TCP/IP 模型四层结构的功能。举例说明传输层和互联网层在发送网页请求时所起的作用。
Solution – The TCP/IP model comprises: Application layer (provides network services to apps, e.g. HTTP, FTP); Transport layer (ensures reliable data transfer, e.g. TCP breaks data into packets, numbers them, and reassembles them); Internet layer (addresses and routes packets across networks, using IP); Network Access layer (handles the physical transmission over hardware).
解答——TCP/IP 模型包括:应用层(为应用程序提供网络服务,如 HTTP、FTP);传输层(确保可靠数据传输,例如 TCP 将数据分片、编号并重组);互联网层(使用 IP 进行寻址和跨网络路由);网络接入层(处理硬件上的物理传输)。
Example: When a browser requests a web page, the Application layer uses HTTP to format the GET request. The Transport layer (TCP) takes this data, splits it into packets, adds sequence numbers and port numbers (e.g. destination port 80). The Internet layer adds source and destination IP addresses to each packet, making them IP datagrams, and determines the best route. The Network Access layer then converts these frames into electrical/optical signals for transmission.
示例:浏览器请求网页时,应用层使用 HTTP 格式化 GET 请求。传输层(TCP)接收该数据,将其分割为数据包,添加序号和端口号(如目标端口 80)。互联网层为每个数据包添加源和目标 IP 地址,形成 IP 数据报,并确定最佳路径。网络接入层再将这些帧转换为电/光信号进行发送。
6. Data Compression & Audio Sampling | 数据压缩与音频采样
Question: A 3-minute stereo recording is made with a sample rate of 44.1 kHz and a 16-bit sample resolution. Calculate the raw file size in megabytes (1 MB = 106 bytes). Then explain how lossy compression could reduce the file size.
问题:一段 3 分钟立体声录音使用 44.1 kHz 采样率和 16 位采样精度。计算原始文件大小,单位为兆字节(1 MB = 106 字节)。然后说明有损压缩如何减小文件大小。
Solution – Raw size: Total samples = sample rate × duration in seconds × number of channels = 44100 × (3×60) × 2 = 44100 × 180 × 2 = 15,876,000 samples. Each sample uses 16 bits = 2 bytes, so total bits = 15,876,000 × 16 = 254,016,000 bits, or total bytes = 15,876,000 × 2 = 31,752,000 bytes. Convert to MB: 31,752,000 ÷ 1,000,000 = 31.752 MB.
解答——原始大小:总采样数 = 采样率 × 时长(秒)× 声道数 = 44100 × (3×60) × 2 = 44100 × 180 × 2 = 15,876,000 次采样。每个采样 16 位 = 2 字节,因此总字节数 = 15,876,000 × 2 = 31,752,000 字节。转换为 MB:31,752,000 ÷ 1,000,000 = 31.752 MB。
Lossy compression: Techniques such as MP3 encoding exploit limitations of human hearing (perceptual coding). It discards audio frequencies that are less audible, for example very high or masked frequencies, and reduces precision where the ear is less sensitive. This drastically reduces file size while maintaining perceived quality.
有损压缩:如 MP3 编码利用人类听觉的局限性(感知编码)。它丢弃听感上不明显的音频频率,例如极高或被掩蔽的频率,并在人耳不敏感的区域降低精度。这能大幅缩减文件大小,同时保持听感质量。
7. Programming: String Manipulation & Loops | 编程:字符串处理与循环
Question: Write a Python program that asks the user to enter a sentence, then outputs the total number of vowels (a, e, i, o, u) and the number of consonants. Ignore case and non-letter characters.
问题:编写一个 Python 程序,要求用户输入一个句子,然后输出元音(a, e, i, o, u)总数和辅音总数。忽略大小写和非字母字符。
Solution – Python code:
sentence = input("Enter a sentence: ")
vowels = "aeiou"
v_count = 0
c_count = 0
for ch in sentence.lower():
if ch.isalpha():
if ch in vowels:
v_count += 1
else:
c_count += 1
print("Vowels:", v_count)
print("Consonants:", c_count)
Explanation: The program converts the input to lowercase to handle case. The isalpha() method ensures only letters are counted. For each letter, it checks membership in the vowel string; if found, increments vowel counter, otherwise consonant counter.
解释:程序将输入转为小写以处理大小写问题。isalpha() 方法确保只统计字母。对于每个字母,检查它是否在元音字符串中;如果在,元音计数器加一,否则辅音计数器加一。
8. Network Security: SQL Injection & Prevention | 网络安全:SQL 注入与防护
Question: A website uses the following SQL query to authenticate users: SELECT * FROM users WHERE username='"+userInput+"' AND password='"+passInput+"'. Explain how an attacker could exploit this with an SQL injection attack and describe one method to prevent it.
问题:一个网站使用以下 SQL 语句验证用户:SELECT * FROM users WHERE username='"+userInput+"' AND password='"+passInput+"'。解释攻击者如何利用 SQL 注入攻击,并描述一种防范方法。
Solution – Attack: An attacker could enter ' OR '1'='1 into the username field and leave the password blank. The resulting query becomes: SELECT * FROM users WHERE username='' OR '1'='1' AND password=''. Because ‘1’=’1′ is always true, the condition evaluates to true, returning all rows and potentially bypassing authentication.
解答——攻击:攻击者可以在用户名字段输入 ' OR '1'='1,并留空密码。形成的查询为:SELECT * FROM users WHERE username='' OR '1'='1' AND password=''。由于 ‘1’=’1′ 恒真,整个条件为真,可能返回所有记录并绕过认证。
Prevention: Use parameterised queries (prepared statements) whereby the SQL code is sent to the database separately from the data values. Placeholders are used for user input, so the database treats the input as data, not executable code. For example, in Python with SQLite: cursor.execute("SELECT * FROM users WHERE username=? AND password=?", (userInput, passInput)). This neutralises injection attempts.
防范措施:使用参数化查询(预备语句),即 SQL 代码与数据值分开发送到数据库。用户输入使用占位符,数据库将其视为数据而非可执行代码。例如 Python 中使用 SQLite:cursor.execute("SELECT * FROM users WHERE username=? AND password=?", (userInput, passInput))。这样可以消除注入企图。
9. Von Neumann Architecture & CPU Performance | 冯·诺依曼结构与 CPU 性能
Question: Describe the fetch-decode-execute cycle in a Von Neumann architecture processor. Explain how increasing the clock speed can improve performance but also mention one drawback.
问题:描述冯·诺依曼架构处理器中的取指-译码-执行周期。说明提高时钟频率如何提升性能,并提及一个缺点。
Solution – FDE cycle: The CPU fetches the next instruction from memory (address held in the Program Counter). The instruction is copied to the Current Instruction Register (CIR). The PC is incremented. The control unit decodes the instruction. The CPU then executes it, which may involve the ALU and accessing memory again for operands. The cycle repeats.
解答——FDE 周期:CPU 从内存中取出下一条指令(地址保存在程序计数器中)。指令被复制到当前指令寄存器(CIR)。PC 自动递增。控制单元对指令进行译码。然后 CPU 执行指令,可能涉及算术逻辑单元 (ALU) 并再次访问内存以获取操作数。周期不断重复。
Clock speed: The clock generates regular pulses that synchronise all CPU operations. A higher clock speed (more cycles per second, measured in GHz) means more FDE cycles can be completed in a given time, increasing processing speed. Drawback: higher clock speed generates more heat and consumes more power, which can lead to overheating and thermal throttling, requiring better cooling solutions.
时钟频率:时钟产生规律脉冲,同步所有 CPU 操作。更高的时钟频率(每秒更多周期,单位为 GHz)意味着单位时间内可完成更多 FDE 周期,从而提升处理速度。缺点:更高的时钟频率产生的热量和功耗更大,可能导致过热和降频,需要更完善的散热方案。
10. Error Detection: Parity & Checksums | 错误检测:奇偶校验与校验和
Question: An 8-bit byte 11010011 is about to be transmitted. If even parity is used, what should the parity bit be? During transmission, the byte is received as 11010111 with parity bit 1. Determine whether an error has been detected, and explain the limitation of simple parity checking.
问题:一个8位字节 11010011 即将被发送。若使用偶校验,校验位应该是什么?传输过程中,接收到的字节为 11010111,校验位为 1。判断是否检测到错误,并解释简单奇偶校验的局限性。
Solution – Parity bit: Count the number of 1s in 11010011: there are five 1s (odd). Even parity requires an even total number of 1s including the parity bit, so the parity bit must be 1 to make the total count 6 (even). Therefore, the parity bit is 1.
解答——校验位:计算 11010011 中 1 的个数:共有五个 1(奇数)。偶校验要求包括校验位在内的 1 的总数为偶数,因此校验位必须为 1,使得总数为 6(偶数)。所以校验位为 1。
Error detection: The received byte 11010111 has six 1s (even number). With the parity bit 1, the total 1 count is 7, which is odd. Since the system expects even parity, an error is detected. Limitation: single parity can only detect an odd number of bit errors; if two bits are flipped, the parity remains correct and the error goes undetected.
错误检测:接收到的字节 11010111 有六个 1(偶数)。加上校验位 1 后,1 的总数为 7,是奇数。而系统预期为偶校验,因此检测到错误。局限性:简单奇偶校验只能检测到奇数个位错误;如果有两个位发生翻转,校验位仍然正确,错误将无法检测出来。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply