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

Case Study Practical Exercises | 案例分析实战演练

2026-07-19 01:02 · 本文部分内容由AI辅助创作

📚 Case Study Practical Exercises | 案例分析实战演练

In Year 9 WJEC Computer Science, case studies are an excellent way to connect theoretical knowledge with real‑world problem‑solving. This article presents a series of practical exercises covering key topics such as cybersecurity, algorithms, data representation, flowcharts, pseudocode, databases, networks, and data validation. Each case is followed by a step‑by‑step analysis to help you develop computational thinking and exam‑ready skills.

在 Year 9 WJEC 计算机科学课程中,案例分析是将理论知识与实际问题解决联系起来的绝佳方式。本文通过一系列实战练习,覆盖网络安全、算法、数据表示、流程图、伪代码、数据库、网络和数据验证等核心主题。每个案例都附有逐步分析,以帮助你培养计算思维,并做好考试准备。


1. Phishing Email Analysis | 钓鱼邮件分析

You receive an email that appears to come from your school IT department. The subject is "Urgent: Password Expiry – Verify Your Account". The email contains your full name, the school logo, and a link to a website that looks identical to the school portal. However, the sender’s address is admin@sch0ol‑portal.net (note the number 0 instead of the letter o).

你收到一封看似来自学校 IT 部门的邮件,主题为“紧急:密码过期 – 验证你的账户”。邮件中包含你的全名、校徽,以及一个看起来与学校门户一模一样的网站链接。然而,发件人地址是 admin@sch0ol‑portal.net(注意数字 0 代替了字母 o)。

This is a classic phishing attempt. The urgency in the subject line pressures the recipient to act without thinking. The spoofed domain uses a homoglyph attack (0 vs o). A legitimate school portal would use the official domain and never ask for password verification via an unsolicited email. Before clicking, you should check the URL by hovering over the link, report the email, and never enter login details on a page reached from a suspicious link.

这是一个典型的网络钓鱼攻击。主题行中的紧迫感迫使收件人不假思索地行动。伪造的域名使用了同形字符攻击(0 与 o)。真正的学校门户会使用官方域名,绝不会通过不请自来的邮件要求验证密码。在点击之前,你应该将鼠标悬停在链接上检查 URL,报告该邮件,并且绝不在从可疑链接进入的页面输入登录信息。

Preventive measures include enabling two‑factor authentication, using anti‑phishing toolbars, and educating users about social engineering. Phishing relies on deception rather than technical hacking, so awareness is the strongest defence.

预防措施包括启用双因素认证、使用反钓鱼工具栏,以及对用户进行社会工程学教育。网络钓鱼依赖欺骗而非技术性入侵,因此提高意识是最有力的防御。


2. Algorithmic Thinking – Number Guessing Game | 算法思维 – 猜数字游戏

A friend challenges you to guess a number between 1 and 100. After each guess, they only tell you "too high" or "too low". You want to guarantee finding the number in the fewest guesses possible. What algorithm should you use, and what is the maximum number of guesses required?

一位朋友要你猜一个 1 到 100 之间的数字。每次猜测后,他只告诉你“太高”或“太低”。你想用尽可能少的猜测次数保证找到数字。你应该使用哪种算法?最多需要猜测多少次?

aximum number of guesses is the number of times you can halve 100 until you reach 1, which is log₂(100) ≈ 6.64, so at most 7 guesses. Binary search is an O(log n) algorithm and demonstrates the power of divide and conquer.

最佳策略是二分查找。从中间值 50 开始猜。根据反馈,每次将搜索范围减半。最大猜测次数是能够将 100 反复对半直到 1 的次数,即 log₂(100) ≈ 6.64,因此最多 7 次猜测。二分查找是一种 O(log n) 的算法,展示了分治法的威力。

This scenario also illustrates the importance of sorting: binary search only works on ordered data. In computing terms, the guessing game is analogous to searching a sorted array. A linear search would require up to 100 guesses, highlighting the efficiency gain.

该场景也说明了排序的重要性:二分查找仅适用于有序数据。在计算机术语中,猜数字游戏类似于在排序数组中搜索。线性搜索最多需要 100 次猜测,凸显了效率的提升。


3. Data Representation – Bitmap Images & Colour Depth | 数据表示 – 位图图像与颜色深度

or a school project. They use a colour depth of 4 bits per pixel. Calculate the file size of the uncompressed image in bytes. Later, they increase the colour depth to 8 bits. How does this affect the file size and the number of available colours?

一名学生为学校项目创建了一个 16×16 像素的图标。他们使用每像素 4 位的颜色深度。计算未压缩图像的文件大小(以字节为单位)。后来,他们把颜色深度增加到 8 位。这对文件大小和可用颜色数量有何影响?

depth becomes 8 bits per pixel, total bits = 256 × 8 = 2048 bits, file size = 256 bytes. The number of possible colours jumps from 2⁴ = 16 to 2⁸ = 256. Larger colour depth greatly improves image quality but increases storage requirements.

对于 16×16 的网格,总像素 = 256。每像素 4 位时,总位数 = 256 × 4 = 1024 位。因 1 字节 = 8 位,文件大小 = 1024 / 8 = 128 字节。当颜色深度变为每像素 8 位,总位数 = 256 × 8 = 2048 位,文件大小 = 256 字节。可显示的颜色数量从 2⁴ = 16 种跃升至 2⁸ = 256 种。更高的颜色深度显著改善图像质量,但增加了存储需求。

Metadata such as width, height, and colour palette would add a few extra bytes in a real bitmap file, but the core calculation remains the same. Understanding the trade‑off between quality and file size is essential when choosing image formats for web or print.

在实际位图文件中,宽度、高度和调色板等元数据会增加少量额外字节,但核心计算相同。在为网页或印刷选择图像格式时,理解质量与文件大小之间的权衡至关重要。


4. Flowchart Interpretation – Factorial Calculation | 流程图解析 – 阶乘计算

ng description of a flowchart designed to compute the factorial of a positive integer N (N! = 1 × 2 × 3 × … + 1, and it loops back. If false, it outputs Fact. Identify any potential flaw when N = 0.

研究下面描述的计算正整数 N 的阶乘(N! = 1 × 2 × 3 × … × N)的流程图。流程图从输入 N 开始,然后初始化 Fact = 1 和计数器 i = 1。一个判断框检查 i ≤ N 是否成立。若成立,则 Fact = Fact × i,然后 i = i + 1,并返回循环;若不成立,则输出 Fact。请指出当 N = 0 时可能存在的缺陷。

Mathematically, 0! is skipped and Fact remains at 1. The output is 1, which is correct. But the flowchart lacks explicit handling for negative input. A robust solution should include a validation check that N is a non‑ he factorial. This case teaches the importance of boundary conditions in algorithm design.

数学上,0! = 1。但在所述流程图中,若 N = 0,条件 i ≤ N(i = 1 ≤ 0)立即为假,因此跳过循环,Fact 保持为 1,输出为 1,结果正确。但该流程图缺少对负输入的显式处理。一个健壮的解决方案应在计算阶乘之前进行验证,确保 N 为非负整数。这个案例告诉我们算法设计中边界条件的重要性。

Flowcharts use standard symbols: oval for start/end, parallelogram for input/output, rectangle for process, and diamond for decision. Being able to trace a flowchart step‑by‑step is a fundamental skill for debugging and understanding program logic.

流程图使用标准符号:椭圆形表示开始/结束,平行四边形表示输入/输出,矩形表示处理,菱形表示判断。能够逐步追踪流程图是调试和理解程序逻辑的基本技能。


广告 / Sponsored

5. Pseudocode Practice – Calculating Average | 伪代码练习 – 计算平均值

Write a pseudocode algorithm that asks the user to enter five test scores, each out of 100, and then calculates and displays the average score. If the average is 50 or above, the program outputs "Pass"; otherwise, it outputs "Fail". Include a loop and appropriate variable declarations.

编写一个伪代码算法,要求用户输入五个测试分数(每项满分 100),然后计算并显示平均分。如果平均分达到 50 或以上,程序输出“Pass”;否则输出“Fail”。请包含循环和合适的变量声明。

A clear solution in pseudocode:
DECLARE total, score, average AS REAL
DECLARE count AS INTEGER
total ← 0
FOR count ← 1 TO 5
 OUTPUT "Enter score ", count
 INPUT score
 total ← total + score
NEXT count
average ← total / 5
OUTPUT "Average = ", average
IF average ≥ 50 THEN
 OUTPUT "Pass"
ELSE
 OUTPUT "Fail"
ENDIF

一种清晰的伪代码解决方案:
DECLARE total, score, average AS REAL
DECLARE count AS INTEGER
total ← 0
FOR count ← 1 TO 5
 OUTPUT "Enter score ", count
 INPUT score
 total ← total + score
NEXT count
average ← total / 5
OUTPUT "Average = ", average
IF average ≥ 50 THEN
 OUTPUT "Pass"
ELSE
 OUTPUT "Fail"
ENDIF

Pseudocode should be language‑agnostic but use consistent indentation and assignment arrows (←). The FOR loop iterates exactly five times, making the code readable and efficient. Translating such a plan into Python or another language becomes straightforward.

伪代码应与语言无关,但应使用一致的缩进和赋值箭头(←)。FOR 循环恰好迭代五次,使代码可读且高效。将这样的规划转换为 Python 或其他语言就变得直接明了。


6. Database Query – School Library System | 数据库查询 – 学校图书馆系统

A school library uses a database table Books with the fields: BookID (integer, primary key), Title (text), Author (text), Genre (text), and CopiesAvailable (integer). Write an SQL‑like query to find all titles and authors of books in the "Science Fiction" genre where there is at least one copy available. Then write a query to count how many distinct genres exist in the table.

学校图书馆用了一个数据库表 Books,包含字段:BookID(整数,主键)、Title(文本)、Author(文本)、Genre(文本)和 CopiesAvailable(整数)。写一个类似 SQL 的查询,找出所有“Science Fiction”类型中至少有一本可借的书的书名和作者。再写一个查询,统计表中存在多少种不同的类型。

Query 1:
SELECT Title, Author
FROM Books
WHERE Genre = 'Science Fiction' AND CopiesAvailable >= 1;
Query 2:
SELECT COUNT(DISTINCT Genre)
FROM Books;

查询 1:
SELECT Title, Author
FROM Books
WHERE Genre = 'Science Fiction' AND CopiesAvailable >= 1;
查询 2:
SELECT COUNT(DISTINCT Genre)
FROM Books;

The WHERE clause filters rows based on conditions, while DISTINCT removes duplicate genre entries before counting. Understanding basic data retrieval is essential for managing information systems. Real‑world databases also require considerations such as indexing to speed up queries.

WHERE 子句根据条件筛选行,而 DISTINCT 在计数前去除重复的类型条目。理解基本的数据检索方法对管理信息系统至关重要。实际数据库还需要考虑建立索引以加速查询等因素。


7. Network Topology – Choosing Star vs Bus | 网络拓扑 – 星型与总线型的选择

A small start‑up company with ten employees plans to set up an office network. They want high reliability and easy troubleshooting but have a limited budget. Compare star and bus topologies in terms of cable requirement, fault tolerance, and scalability, and recommend a suitable topology with justification.

一家有十名员工的小型初创公司计划搭建办公室网络。他们希望高可靠性和易于排除故障,但预算有限。从线缆需求、容错性和可扩展性三个方面比较星型和总线型拓扑,并推荐一个合适的拓扑,给出理由。

FeatureStarBus
Cable requirementMore cable (each node to central switch)Less cable (single backbone)
Fault toleranceHigh – one cable failure affects only that nodeLow – a backbone break downs the whole network
ScalabilityEasy to add nodes without disruptionDifficult – adding nodes may require terminators and disrupt traffic

Given the emphasis on reliability and trouble‑shooting, a star topology is the better choice. Although it uses more cable and requires a switch, the ability to isolate faults and expand easily outweighs the initial cost. Modern Ethernet LANs almost exclusively use star or extended star designs.

鉴于对可靠性和故障排除的重视,星型拓扑是更好的选择。尽管它使用更多线缆且需要交换机,但隔离故障和易于扩展的能力胜过初始成本。现代以太局域网几乎都采用星型或扩展星型设计。


8. Data Validation & Verification – Online Form Entry | 数据验证与校验 – 在线表单输入

An online registration form requires the user to enter their age (between 5 and 120), email address, and a password twice. Identify appropriate validation and verification techniques for each field, and explain the difference between validation and verification.

一个在线注册表单要求用户输入年龄(5 到 120 岁之间)、电子邮件地址,并两次输入密码。请为每个字段选择合适的验证和校验技术,并解释验证与校验之间的区别。

For age, use a range check (5–120) and a presence check to ensure it is not left blank. For email, a format check using a regular expression can confirm the presence of '@' and a domain. The double password entry is a verification method: both entries are compared to ensure they match, reducing the chance of a typing error. Validation catches data that is unreasonable or impossible, while verification checks that data has been entered correctly.

对年龄,使用范围检查(5–120)和存在性检查以确保不为空。对电子邮件,使用格式检查,通过正则表达式确认包含“@”和域名。两次输入密码是一种校验方法:比较两次输入以确保一致,减少输入错误的可能性。验证用于捕获不合理或不可能的数据,而校验检查数据是否正确录入。

Additional techniques such as check digits (e.g. on barcodes) and parity bits for data transmission are examples of verification at the hardware level. A well‑designed system combines both validation and verification to maintain data integrity.

其他技术,如校验位(如条形码上的)和数据传输中的奇偶校验位,是硬件层面校验的示例。一个设计良好的系统会结合验证和校验来维护数据完整性。


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

广告 / Sponsored
Linux高级程序设计(高等院校计算机技术十二五规划教材)/刘加海/季江民/浙江大学出版社
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥55.6

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

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