📚 Case Study Practice for Year 12 CIE Computer Science | 案例分析实战演练
A case study question in CIE Computer Science AS Level tests your ability to analyse a real-world scenario, design data structures, develop algorithms, and write clear pseudocode. This guide takes you through a complete worked example – a library management system – to build the skills you need for Section B of Paper 2. You will learn how to break down requirements, choose appropriate data types, structure a program using modular design, handle file operations, and validate user input, all using the Cambridge-style pseudocode you are expected to produce in the exam. By working step by step, you can master the case study approach and avoid common pitfalls.
在 CIE 计算机科学 AS 阶段的案例分析题中,你需要分析一个真实场景、设计数据结构、开发算法并写出清晰的伪代码。本指南将以一个完整的实战示例——图书馆管理系统——带你逐步建立 Paper 2 B 部分所需的技能。你将学会如何分解需求、选择合适的数据类型、利用模块化设计组织程序、处理文件操作以及验证用户输入,所有内容均采用考试中要求的 Cambridge 风格伪代码。通过一步步的练习,你可以掌握案例分析方法,避开常见错误。
1. Understanding the Scenario | 理解场景
Begin by reading the case study brief several times. Identify the key entities, constraints, and required functionality. For our example, a local library needs a program to manage book loans. The system must store details of up to 5000 books and 1000 members. Each book has a unique ISBN, title, author, and a loan status (available or on loan). Members have a unique ID, name, and a count of books currently on loan, which cannot exceed five. The system should support searching for books by title or author, borrowing a book, returning a book, and displaying all books currently on loan by a specific member.
首先要反复阅读案例简介,找出关键实体、约束条件和所需功能。在我们的示例中,一家本地图书馆需要一个程序来管理图书借阅。系统必须存储最多 5000 本书和 1000 名会员的数据。每本书有唯一的 ISBN、书名、作者和借阅状态(可借或已借出)。会员有唯一的 ID、姓名和当前借阅数量,且不能超过 5 本。系统需要支持按书名或作者搜索图书、借书、还书,以及显示特定会员当前借阅的所有图书。
2. Identifying Inputs, Processes and Outputs | 识别输入、处理与输出
Use a structured approach to list the main inputs, processes, and outputs. Inputs include member ID, book ISBN, search text, and menu choices. The core processes are updating loan records, checking availability, and processing returns. Outputs are confirmation messages, lists of search results, and loan summaries. Drawing IPO charts for each module helps you map data flow before writing any code. For the ‘borrow book’ process, the inputs are member ID and book ISBN; the process checks maximum loans, verifies book availability, reduces available copies, and increments the member’s loan count; outputs include success or failure messages.
采用结构化方法列出主要的输入、处理和输出。输入包括会员 ID、图书 ISBN、搜索文本和菜单选项。核心处理包括更新借阅记录、检查可借状态和处理还书。输出则是确认消息、搜索结果列表和借阅摘要。为每个模块绘制 IPO 图可以在编写代码前理清数据流。对于“借书”过程,输入为会员 ID 和图书 ISBN;处理环节会检查最大借阅数量、验证图书可借状态、减少可借本数并增加会员借阅计数;输出包括成功或失败消息。
3. Data Structures and Variable Types | 数据结构与变量类型
Decide how to store data in memory, considering global arrays for exam simplicity. Declare two 1D arrays for books and members, or parallel arrays if using the syllabus-recommended style. For books, we might use ARRAY [1:5000] OF STRING for ISBNs, titles, and authors, along with an ARRAY OF BOOLEAN for availability. For members, ARRAY [1:1000] OF INTEGER for IDs, ARRAY OF STRING for names, and ARRAY OF INTEGER for active loans. Define constants such as MAX_BOOKS = 5000 and MAX_LOANS = 5. Use INTEGER, STRING, BOOLEAN, and CHAR as appropriate; for example, menu options might be CHAR to simplify input handling.
决定如何在内存中存储数据,考试中通常使用全局数组以简化设计。我们可以为图书和会员各声明一维数组,或者采用大纲推荐的平行数组风格。对于图书,可以使用 ARRAY [1:5000] OF STRING 存储 ISBN、书名和作者,再配合一个 ARRAY OF BOOLEAN 作为借出状态。对于会员,使用 ARRAY [1:1000] OF INTEGER 存储 ID,ARRAY OF STRING 存储姓名,ARRAY OF INTEGER 存储当前借阅数量。定义常量如 MAX_BOOKS = 5000 和 MAX_LOANS = 5。根据情况使用 INTEGER、STRING、BOOLEAN 和 CHAR;例如,菜单选项用 CHAR 可简化输入处理。
4. Modular Design and Top-down Approach | 模块化设计与自顶向下方法
Break the system into subroutines, each handling one clear responsibility. A main procedure displays a menu and calls functions such as SearchBook, BorrowBook, ReturnBook, and ShowMemberLoans. Using a top-down refinement, first define the top-level algorithm as a loop that reads a choice and dispatches to the appropriate module. This makes your solution easier to follow and allows you to write pseudocode piece by piece. Each subroutine should receive parameters and return values as necessary, avoiding overuse of global variables to keep functions independent.
将系统分解为子程序,每个子程序负责一个清晰的功能。主过程显示菜单并调用 SearchBook、BorrowBook、ReturnBook 和 ShowMemberLoans 等函数。采用自顶向下逐步求精的方法,首先将顶层算法定义为一个循环,读入选项并调用对应模块。这样你的解答更易于理清,也可以逐段书写伪代码。每个子程序应按需要接收参数并返回值,尽量避免过度使用全局变量以保持函数的独立性。
5. Algorithm Design: Searching and Sorting | 算法设计:查找与排序
Searching is a core requirement. Use linear search across the arrays because data is not guaranteed to be sorted. For a search by title, iterate through the title array and compare each element with the target string; partial matching can be implemented using pseudocode string functions if the syllabus allows. When displaying results, you may need to sort the output by author or availability. A simple bubble sort can be applied to a list of indices to avoid moving large records. Explain your choice of algorithm and state its time complexity in Big O notation, e.g. O(n) for linear search.
查找是核心需求。由于数据不一定有序,我们使用数组上的线性搜索。按书名搜索时,遍历书名数组并将每个元素与目标字符串比较;如果大纲允许,可用伪代码字符串函数实现部分匹配。显示结果时,可能需要按作者或可借状态排序输出。可以用简单的冒泡排序对索引列表排序,从而避免移动大记录。解释你的算法选择并用大 O 表示法写明其时间复杂度,例如线性搜索为 O(n)。
6. Pseudocode for Core Functions | 核心函数的伪代码
Write exam-ready pseudocode for the key operations. Use Cambridge conventions: DECLARE, INPUT, OUTPUT, IF … THEN … ELSE … ENDIF, FOR … NEXT, WHILE … ENDWHILE, and FUNCTION … RETURNS data type. Here is an example for borrowing a book, assuming arrays are global and indexed from 1 to last count:
为关键操作编写可直接用于考试的伪代码。使用 Cambridge 风格:DECLARE、INPUT、OUTPUT、IF … THEN … ELSE … ENDIF、FOR … NEXT、WHILE … ENDWHILE 和 FUNCTION … RETURNS 数据类型。以下是借书函数的示例,假设数组为全局变量且索引从 1 到当前记录数:
FUNCTION BorrowBook(memberID: INTEGER, bookISBN: STRING) RETURNS BOOLEAN
DECLARE memberIndex, bookIndex, memberLoans: INTEGER
memberIndex ← FindMember(memberID)
IF memberIndex = -1 THEN
OUTPUT “Member not found”
RETURN FALSE
ENDIF
memberLoans ← MemberLoans[memberIndex]
IF memberLoans >= MAX_LOANS THEN
OUTPUT “Loan limit reached”
RETURN FALSE
ENDIF
bookIndex ← FindBook(bookISBN)
IF bookIndex = -1 OR NOT BookAvailable[bookIndex] THEN
OUTPUT “Book not available”
RETURN FALSE
ENDIF
BookAvailable[bookIndex] ← FALSE
MemberLoans[memberIndex] ← MemberLoans[memberIndex] + 1
OUTPUT “Book borrowed successfully”
RETURN TRUE
ENDFUNCTION
Keep each function short and focused; you can reference other helper functions such as FindMember and FindBook, which perform linear searches and return the array index or -1 if not found. Always handle the ‘not found’ case to make your solution robust.
保持每个函数简短且专注;你可以引用其他辅助函数如 FindMember 和 FindBook,它们执行线性搜索并返回数组索引,未找到则返回 -1。务必处理“未找到”的情况,使你的方案更健壮。
7. Handling File Operations | 处理文件操作
If the scenario requires persistent storage, use pseudocode file statements: OPENFILE FOR READ/WRITE, READFILE, WRITEFILE, and CLOSEFILE. For simplicity, assume the data files are text files with one record per line. On program start, read book and member data into arrays; on exit, write updated arrays back to files. Always check for end-of-file using EOF() and handle file-not-found errors with a suitable message. This demonstrates awareness of real-world data handling even within pseudocode constraints.
如果场景要求持久化存储,使用伪代码的文件语句:OPENFILE <文件名> FOR READ/WRITE、READFILE、WRITEFILE 和 CLOSEFILE。为简单起见,假设数据文件为文本文件,每条记录占一行。程序启动时将图书和会员数据读入数组;退出时将更新后的数组写回文件。务必使用 EOF() 检测文件结束,并通过合适的信息处理“文件未找到”错误。这显示了你即使在伪代码限制下也注意到了实际数据处理。
8. Testing and Validation | 测试与验证
Design a test plan covering normal, boundary, and erroneous data. For borrowing a book, normal data might be a valid member and an available book. Boundary tests include a member with exactly four loans trying to borrow one more (should succeed) and one with five loans (should fail). Erroneous tests include non-existent member ID, non-existent ISBN, and empty input. Use a table to document your test cases:
设计一份包含正常、边界和异常数据的测试计划。对于借书操作,正常数据可以是一个有效会员和一本可借的书。边界测试包括已借 4 本的会员再借一本(应成功)和已借 5 本的会员尝试再借(应失败)。异常测试包括不存在的会员 ID、不存在的 ISBN 和空输入。用表格记录测试用例:
| Test Case | Input Data | Expected Outcome |
| Normal borrow | Member 102, ISBN ‘978-0-123-45678-0’ (available) | Success message, loan count incremented |
| Boundary max loans | Member with 5 loans, any ISBN | “Loan limit reached” error |
| Invalid member ID | Member 9999, valid ISBN | “Member not found” error |
Explain how you would use these tests to verify the logic step by step, and suggest the use of trace tables to follow variable values in complex algorithms.
说明你将如何使用这些测试逐步验证逻辑,并建议在复杂算法中使用跟踪表跟踪变量值。
9. Trace Table Walkthrough | 跟踪表演练
A trace table is essential for demonstrating how your algorithm works. Take the BorrowBook function and construct a trace for a successful borrow. Columns include the function call line, memberIndex, bookIndex, memberLoans, and output. For a call with member index 3 (loans = 2) and book index 5 (available), the trace shows the sequence of comparisons, updates to memberLoans from 2 to 3, and BookAvailable[5] changing to FALSE. Practise producing trace tables by hand; exam questions often ask you to complete one, and showing the internal state step by step helps you catch logic errors early.
跟踪表是展示算法运行过程的关键工具。以 BorrowBook 函数为例,为一次成功借书构造跟踪表。各列包括函数调用行、memberIndex、bookIndex、memberLoans 和输出。对于 member index=3(loans=2)且 book index=5(可借)的调用,跟踪表显示比较顺序,memberLoans 从 2 更新为 3,BookAvailable[5] 变为 FALSE。练习手动绘制跟踪表;考试中常要求你补全跟踪表,而逐步展示内部状态有助于及时发现逻辑错误。
10. Error Handling and Robustness | 错误处理与健壮性
Robust solutions anticipate invalid inputs and exceptional conditions. Use input validation loops (REPEAT … UNTIL) for menu choices, and check for numeric types when reading integers. For file operations, verify that the file has been opened successfully before reading. In the pseudocode, you can use TRY … EXCEPT structures if your syllabus includes them; otherwise, use conditional checks. Always provide meaningful error messages rather than generic ‘error’ outputs. This marks the difference between a basic and a high-band answer.
健壮的方案会预判无效输入和异常情况。对菜单选项使用输入验证循环(REPEAT … UNTIL),并在读取整数时检查数值类型。对于文件操作,在读取前验证文件是否成功打开。如果大纲包含异常处理,可在伪代码中使用 TRY … EXCEPT 结构;否则用条件判断。始终给出有意义的错误信息,而不是笼统的“错误”输出。这正是区分基础档和高分档答案的关键。
11. Evaluation and Refinement | 评估与改进
After writing your solution, evaluate it against the original specification. Does it meet all functional requirements? Can it handle the maximum data volumes without significant delay? Consider alternative data structures: a 2D array could consolidate book records and reduce parallel array complexity, but may be less readable under exam conditions. Discuss trade-offs, such as choosing linear search for simplicity versus binary search requiring sorted data. Suggest future enhancements, like adding a fine system for overdue books or moving from arrays to records or object-oriented structures if the syllabus permits. This critical evaluation shows examiners you think like a developer.
写完方案后,对照原始规格进行评估。它是否满足所有功能需求?是否能在没有明显延迟的情况下处理最大数据量?考虑替代数据结构:二维数组合并图书记录可以减少平行数组的复杂度,但在考试环境下可能可读性较差。讨论折衷选择,比如为简单而选择线性搜索,而二分搜索则要求预先排序。提出未来改进,例如增加逾期罚款系统,或者如果大纲允许,将数组升级为记录或面向对象结构。这种批判性评估能让考官看到你像开发人员一样思考。
12. Exam Tips for Case Studies | 案例分析考试技巧
In the exam, spend the first 5 minutes annotating the scenario. Highlight constraints (max 5000 books, max 5 loans) and circle every user requirement. Structure your answer with clear headings for data structures, algorithms, and testing. Pseudocode must be syntactically consistent; decide on a single convention and stick to it. If you run out of time, bullet-point your algorithm steps – you can still earn marks for logic. Practise with past CIE papers, especially those featuring pre-release material, to build speed and confidence. Always leave 2 minutes to review your variable declarations and ensure all paths return a value where expected.
考试时,用前 5 分钟标注场景,高亮限制条件(最多 5000 本书、每人最多借 5 本)并圈出每个用户需求。为答案设计清晰的结构,包括数据结构、算法和测试部分。伪代码必须在语法上保持一致;选定一种书写规范并坚持到底。如果时间不够,用要点列出算法步骤——你仍可获得逻辑分。使用 CIE 历年真题练习,尤其是那些包含预发布材料的题目,以提升速度和信心。最后留出 2 分钟检查变量声明,确保所有执行路径在需要返回值的地方都有返回。
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