📚 Case Study Practical Drills | 案例分析实战演练
Case study analysis is a core component of the CIE Pre-U Computer Science examination, demanding more than just coding ability. It tests your capacity to dissect a real-world scenario, abstract its essential features, design a robust solution, and critically evaluate your choices. This article walks you through a hands-on practical drill using a typical exam-style scenario, breaking the process down into manageable stages so you can build confidence and accuracy for Paper 3.
案例分析是 CIE Pre-U 计算机科学考试的核心组成部分,它不仅考验你的编程能力,更要求你能够剖析真实场景、抽象关键特征、设计可靠的解决方案并审慎评估自己的选择。本文将通过一个典型的考试风格场景,带你进行动手实战演练,将整个过程分解为可操作的阶段,帮助你为 Paper 3 建立信心与精准度。
1. Introduction to Case Study Analysis | 案例分析概述
A Pre-U case study typically presents a narrative describing a problem an organisation or individual faces. Your task is to interpret that description, recognise the computational thinking required, and produce a structured report that includes abstraction, decomposition, algorithm design, data structure selection, and evaluation. The examiner is less interested in a perfect program and more in your reasoning process.
Pre-U 的案例分析通常会给出一个叙述,描述某个组织或个人面临的问题。你的任务是解读这种描述、识别所需的计算思维,并生成一份结构化的报告,其中包括抽象、分解、算法设计、数据结构选择和评估。考官更关注你的推理过程,而非一个完美的程序。
In this drill we will work with a scenario: a local library wants a software module to manage its collection of e-books. Users should be able to add a new e-book, borrow a copy, return a copy, search by author or title keyword, and list all e-books sorted by title. Available copies must be tracked and borrowing should be refused when copies reach zero.
在本次演练中,我们将使用如下场景:一家地方图书馆希望有一个软件模块来管理其电子书收藏。用户应能添加新电子书、借阅一本、归还一本、按作者或标题关键词搜索,以及按标题排序列出所有电子书。可借阅的副本数量必须被跟踪,且当副本数为零时应拒绝借阅。
2. Decoding the Problem Statement | 解读问题陈述
Start by reading the scenario several times. Underline key nouns – these often become classes, records, or variables. Highlight verbs – they suggest operations or methods. For our library scenario, nouns include ‘e-book’, ‘title’, ‘author’, ‘copies’, and ‘library collection’. Verbs are ‘add’, ‘borrow’, ‘return’, ‘search’, and ‘list sorted’. This initial extraction prevents you from missing functional requirements.
一开始要反复阅读场景。划出关键名词——它们通常会变成类、记录或变量。高亮动词——它们提示了操作或方法。在我们的图书馆场景中,名词有 ‘电子书’、’标题’、’作者’、’副本’ 和 ‘馆藏’。动词有 ‘添加’、’借阅’、’归还’、’搜索’ 和 ‘排序列出’。这种初步提取能避免你遗漏功能性需求。
Also distinguish between functional requirements (what the system must do) and non-functional constraints (limits on storage, speed, or language). The brief mentions ‘sorted by title’, which implies a sorting requirement. It does not mention a graphical interface, so a text-based or logical design is acceptable.
同时要区分功能性需求(系统必须做什么)与非功能性约束(对存储、速度或语言的限制)。题目中提到 ‘按标题排序’,这意味着有排序需求。它没有提及图形界面,所以基于文本或逻辑的设计是可接受的。
3. Identifying Inputs and Outputs | 确定输入与输出
For each operation, define precise inputs and outputs. ‘Add a new e-book’ might take title, author, ISBN, and initial number of copies as input, and output a confirmation or error message. ‘Borrow a copy’ could take the book title or ISBN as input, and output a success message or a ‘no copies available’ warning. Structuring I/O early clarifies the boundaries of your module.
为每个操作定义准确的输入与输出。’添加新电子书’ 可能将标题、作者、ISBN 和初始副本数作为输入,并输出确认或错误信息。’借阅一本’ 可将书名或 ISBN 作为输入,并输出成功信息或 ‘无副本可用’ 的警告。尽早构建输入/输出结构能厘清你的模块边界。
Write these down in a simple table:
| Operation | Inputs | Outputs |
|---|---|---|
| addEbook | title, author, ISBN, copies | confirmation / error |
| borrowCopy | ISBN | success / out of stock |
| returnCopy | ISBN | new available copies count |
| search | keyword, searchType | list of matching e-books |
| listSorted | none | full list sorted by title |
写出这些内容的一个简单表格如下:(操作、输入、输出)
4. Abstraction and Modelling | 抽象与建模
Abstraction means focusing only on the details relevant to the problem. For an e-book, we care about its title, author, ISBN, and availableCopies – not its cover image, file format, or publisher history. Create a record structure or class diagram to represent this:
抽象意味着只关注与问题相关的细节。对于一本电子书,我们关心其标题、作者、ISBN 和可用副本数——而非其封面图片、文件格式或出版历史。创建一个记录结构或类图来表示这些信息:
Ebook = record
title : STRING
author : STRING
isbn : STRING
availableCopies : INTEGER
endrecord
Ebook = record
title : STRING
author : STRING
isbn : STRING
availableCopies : INTEGER
endrecord
Modelling also involves the relationships between entities. Here the library contains many e-books, so a one-to-many relationship is appropriate. This can be represented by an array or a list of Ebook records. Decisions made at this stage will heavily influence later algorithm complexity.
建模还涉及实体之间的关系。这里图书馆包含多本电子书,因此一对多的关系是合适的。这可用一个 Ebook 记录数组或列表来表示。此阶段所做的决策将极大影响后续算法的复杂度。
5. Choosing Appropriate Data Structures | 选择合适的数据结构
Selecting the right data structure is critical for efficiency. We need fast search by ISBN and keyword, and sorting by title. A static array would make insertion and deletion expensive if the collection grows. A dynamic list or dictionary (hash table) keyed by ISBN would give O(1) average access for borrowing and returning. For searching by author or title keyword we could scan the list, but if the library is large, we might maintain a secondary index such as a trie or a sorted array with binary search.
选择正确的数据结构对效率至关重要。我们需要按 ISBN 快速搜索、按关键词检索,以及按标题排序。如果馆藏不断增长,静态数组会使插入和删除代价高昂。用 ISBN 作为键的动态列表或字典(哈希表)可提供借阅和归还的平均 O(1) 访问。对于按作者或标题关键词搜索,我们可以遍历列表,但如果图书馆规模很大,可以维护一个辅助索引,例如一个 trie 或采用二分查找的排序数组。
Given typical Pre-U boundaries, a balanced choice is a hash table for direct ISBN access and a separate dynamic array of references that can be sorted when the ‘listSorted’ operation is called. For keyword search, a linear scan of the array with simple string matching is acceptable unless the scenario explicitly mentions large datasets.
考虑到 Pre-U 的典型边界,一个平衡的选择是:使用哈希表进行直接 ISBN 访问,同时维护一个动态引用数组,在调用 ‘listSorted’ 操作时进行排序。对于关键词搜索,若场景未明确提及庞大数据集,则对数组进行线性扫描和简单字符串匹配是可以接受的。
6. Algorithm Design – Stepwise Refinement | 算法设计 – 逐步求精
Break each operation into smaller steps using a top-down approach. For the ‘borrowCopy(isbn)’ function, the refinement could be:
运用自顶向下的方法将每个操作分解为更小的步骤。对于 ‘borrowCopy(isbn)’ 函数,求精过程可如下:
PROCEDURE borrowCopy(ISBN : STRING)
IF hashTable contains ISBN THEN
Retrieve ebook record
IF ebook.availableCopies > 0 THEN
ebook.availableCopies ← ebook.availableCopies – 1
OUTPUT ‘Borrow successful, copies left: ‘, ebook.availableCopies
ELSE
OUTPUT ‘No copies available’
ENDIF
ELSE
OUTPUT ‘ISBN not found’
ENDIF
ENDPROCEDURE
PROCEDURE borrowCopy(ISBN : STRING)
IF hashTable contains ISBN THEN
Retrieve ebook record
IF ebook.availableCopies > 0 THEN
ebook.availableCopies ← ebook.availableCopies – 1
OUTPUT ‘借阅成功,剩余副本:’, ebook.availableCopies
ELSE
OUTPUT ‘无可用副本’
ENDIF
ELSE
OUTPUT ‘未找到该ISBN’
ENDIF
ENDPROCEDURE
This logical refinement helps when writing pseudocode and later when translating into code. For searching, a simple function that iterates through the array and uses a case-insensitive substring match is often sufficient and easy to trace.
这种逻辑求精有助于编写伪代码,并最终转换为实际代码。对于搜索,一个简单的函数遍历数组并使用不区分大小写的子串匹配通常就足够了,而且容易跟踪。
7. Writing Pseudocode | 编写伪代码
Pre-U pseudocode does not require strict compliance with a single standard, but it must be clear, consistent, and use indentation to show structure. Use standard keywords like INPUT, OUTPUT, IF…THEN…ELSE…ENDIF, WHILE…DO…ENDWHILE, FOR…TO…NEXT, and PROCEDURE. Avoid language-specific syntax (e.g., no print() unless it is explained).
Pre-U 伪代码不要求严格遵守单一标准,但必须清晰、一致,并使用缩进来展示结构。使用标准关键字,如 INPUT、OUTPUT、IF…THEN…ELSE…ENDIF、WHILE…DO…ENDWHILE、FOR…TO…NEXT 和 PROCEDURE。避免使用特定语言的语法(例如,除非作了解释,否则不要使用 print())。
Below is an example for the ‘listSorted’ operation that copies the array of references, sorts them using a basic bubble sort for simplicity (or insertion sort if stability is required), and outputs the titles:
以下为 ‘listSorted’ 操作的示例,该操作复制引用数组,使用基本的冒泡排序进行简单排序(如需稳定性则使用插入排序),并输出标题:
PROCEDURE listSorted
DECLARE sortedList : ARRAY OF Ebook
sortedList ← COPY(allEbooks) // shallow copy of references
FOR i FROM 0 TO LENGTH(sortedList)-2
FOR j FROM 0 TO LENGTH(sortedList)-i-2
IF sortedList[j].title > sortedList[j+1].title THEN
SWAP sortedList[j], sortedList[j+1]
ENDIF
NEXT j
NEXT i
FOR k FROM 0 TO LENGTH(sortedList)-1
OUTPUT sortedList[k].title, ‘ – ‘, sortedList[k].author
NEXT k
ENDPROCEDURE
PROCEDURE listSorted
DECLARE sortedList : ARRAY OF Ebook
sortedList ← COPY(allEbooks) // 引用的浅拷贝
FOR i FROM 0 TO LENGTH(sortedList)-2
FOR j FROM 0 TO LENGTH(sortedList)-i-2
IF sortedList[j].title > sortedList[j+1].title THEN
SWAP sortedList[j], sortedList[j+1]
ENDIF
NEXT j
NEXT i
FOR k FROM 0 TO LENGTH(sortedList)-1
OUTPUT sortedList[k].title, ‘ – ‘, sortedList[k].author
NEXT k
ENDPROCEDURE
8. Trace Tables and Dry Runs | 跟踪表与干运行
Examiners frequently ask you to complete a trace table to prove your algorithm works for a given test data set. Construct a table with columns for each variable and condition. Run through the logic manually, updating variable values step by step. For the borrowCopy procedure above with a sample ISBN ‘123’, assume the ebook ‘Python Basics’ has 2 copies initially.
考官经常要求你完成一个跟踪表,以证明你的算法在给定测试数据集上能正常工作。构建一个表格,列为各变量和条件。手动执行逻辑,逐步更新变量值。对于上述 borrowCopy 过程,假设样例 ISBN 为 ‘123’,电子书 ‘Python Basics’ 初始有 2 个副本。
| Step | ISBN | found? | availableCopies | Output |
|---|---|---|---|---|
| 1 | ‘123’ | TRUE | 2 | – |
| 2 | ‘123’ | TRUE | 1 | ‘Borrow successful, copies left: 1’ |
跟踪表示例。反复练习追踪含有循环和条件的算法,特别是边界情况,如副本数为 0 时。这不仅能强化你的理解,还能提供有力的正确性证据。
9. Complexity Analysis | 复杂度分析
You are expected to discuss the time and space complexity of your algorithms using Big O notation. The ‘borrowCopy’ using a hash table is O(1) in the average case; searching by keyword scanning all n e-books is O(n × m) where m is the average length of the search string. The sorting operation with bubble sort is O(n²), which is acceptable for small collections but could be improved to O(n log n) with merge sort if required.
你需要用大 O 表示法讨论算法的时间和空间复杂度。使用哈希表的 ‘borrowCopy’ 平均情况为 O(1);扫描所有 n 本电子书的关键词搜索为 O(n × m),其中 m 是搜索字符串的平均长度。使用冒泡排序的排序操作为 O(n²),对于小型馆藏可以接受,但如果需要,可改用归并排序将其优化到 O(n log n)。
Always state any assumptions (e.g., ‘assuming a good hash function with minimal collisions’). For space complexity, note that the hash table and array of references require O(n) extra space. Demonstrating awareness of trade-offs (time vs space, simplicity vs efficiency) is a mark of a top-level candidate.
始终要说明任何假设(例如,’假设一个碰撞极少的好哈希函数’)。对于空间复杂度,要注明哈希表和引用数组需要 O(n) 的额外空间。展示对权衡取舍(时间与空间、简单性与效率)的认知,是顶尖考生的一项标志。
10. Testing Strategy and Edge Cases | 测试策略与边界案例
A robust case study answer includes a testing plan. Describe normal, boundary, and erroneous test data. Normal: borrow a book that exists with copies > 0. Boundary: borrow when availableCopies is exactly 1 (should reduce to 0 successfully) or 0 (should refuse). Erroneous: search with an empty keyword, add an e-book with negative copies, borrow an ISBN not in the system.
一份稳健的案例分析答案包含测试计划。描述正常、边界和错误测试数据。正常:借阅一本存在且副本数大于 0 的书。边界:借阅时 availableCopies 恰好为 1(应成功减少至 0)或为 0(应拒绝)。错误:用空关键词搜索、添加副本数为负数的电子书、借阅系统中不存在的 ISBN。
Show expected outcomes for each. For example, adding an e-book with copies = -1 should produce an error message, demonstrating input validation. Handling these in your pseudocode by adding preconditions (e.g., IF copies < 1 THEN OUTPUT 'Invalid copies') strengthens your design.
显示每种情况的预期结果。例如,添加一本 copies = -1 的电子书应产生错误信息,以展示输入验证。在伪代码中通过添加前置条件(如 IF copies < 1 THEN OUTPUT '无效副本数')来处理这些情况,能强化你的设计。
11. Evaluation and Alternatives | 评估与备选方案
Conclude your case study with a critical evaluation. Discuss what worked well – perhaps the hash table meets the rapid lookup requirement perfectly. Then address limitations: the keyword search becomes slow with a huge catalogue, and the bubble sort is inefficient for frequent list operations. Suggest alternatives: a balanced binary search tree could maintain sorted order dynamically, avoiding the need for periodic sorting; a trie could enable faster prefix searches.
以批判性评估结束你的案例分析。讨论哪些方面做得好——或许哈希表完美满足了快速查找的需求。然后谈一谈局限性:关键词搜索在目录庞大时会变慢,而冒泡排序对于频繁的列表操作效率低下。提出备选方案:平衡二叉搜索树可以动态维护有序顺序,从而避免定期排序的需要;trie 可以实现更快的前缀搜索。
This shows higher-order thinking. You should also reference the feasibility of implementation under exam constraints – simpler is often better if the problem size is small. Acknowledge any assumptions and how they might affect the solution’s real-world applicability.
这展示了高阶思维。你还应提及在考试约束下实施的可行性——如果问题规模很小,通常简单方案更佳。承认任何假设,并说明它们会如何影响方案在真实世界中的适用性。
12. Common Pitfalls and Tips | 常见陷阱与技巧
Many students lose marks by diving into code without proper analysis. Always spend time reading the brief, underlining, and drawing a simple diagram before writing any algorithm. Missing a functional requirement (like ‘return a copy’ must increase availableCopies) is a common mistake. Another pitfall is ignoring data validation – examiners expect you to check for invalid inputs.
许多学生因未经充分分析就直接写代码而失分。在编写任何算法之前,务必花时间阅读题目要求、划线并绘制简单图表。遗漏功能性需求(如 ‘归还一本’ 必须增加 availableCopies)是一个常见错误。另一个陷阱是忽略数据验证——考官期望你检查无效输入。
For high marks, make your pseudocode self-contained and well-commented. Use meaningful variable names. Practice with past papers under timed conditions; attempt an entire case study in 45 minutes to build exam stamina. Finally, always link your choices back to the scenario – do not just state ‘I used a hash table because it is fast’, explain why speed matters for this particular library system.
为获得高分,让你的伪代码自包含且注释清晰。使用有意义的变量名。在计时条件下用往年真题练习;尝试在 45 分钟内完成一个完整的案例分析,以培养考试耐力。最后,始终将你的选择与场景联系起来——不要只说 ‘我使用了哈希表因为它快’,而要解释为什么速度对这个特定的图书馆系统很重要。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导