Algorithm Design and Standard Methods: Question 10
Syllabus 7.1, 7.2
A developer is designing a new quiz app called QuizMaster. The app must let a user register, then run a quiz, in which the app asks a series of questions, marks each typed answer, and keeps a running score, and finally show a leaderboard of the top scores from all users.
(a) Decompose QuizMaster into a structure diagram. Your diagram must show a single top-level module for the whole app, at least three second-level modules, and at least two third-level modules nested underneath one of the second-level modules. Represent your structure diagram as an indented hierarchy, clearly showing which module each one belongs under. [5]
(b) State one difference between what a structure diagram shows and what a flowchart shows. [2]
(c) Explain one advantage, other than making the problem easier to understand, of decomposing QuizMaster into the modules shown in your structure diagram before any coding begins. [2]
Show worked solution Hide worked solution
Worked solution
Part (a): Decomposing QuizMaster into a structure diagram
The whole problem is QuizMaster. Looking at the scenario, three clearly separate tasks appear at the top: registering a user, running the quiz itself, and showing a leaderboard. [1] Running the quiz is itself made up of smaller tasks, asking a question, marking the typed answer, and updating the running score, so these belong underneath Run Quiz rather than directly underneath QuizMaster. [2] for correctly nesting at least two of these three sub-modules one level below Run Quiz.
QuizMaster
├── Register User
├── Run Quiz
│ ├── Ask Question
│ ├── Mark Answer
│ └── Update Score
└── Show Leaderboard
[1] for a single top-level module representing the whole app, [1] for at least three second-level modules that are genuine, specific sub-tasks (not just a repeat of the whole problem).
Part (b): Structure diagram vs flowchart
A structure diagram shows what the system is made of: a hierarchy of modules and sub-modules, and which modules belong underneath which, for example, that Ask Question, Mark Answer and Update Score all belong underneath Run Quiz. [1] It does not show the order any of these run in, or any conditions or repetition.
A flowchart shows how a specific algorithm runs: the step-by-step sequence of individual instructions, including decision diamonds and loops, such as the exact order in which a question is asked, an answer is checked, and the score is updated within Run Quiz. [1]
Part (c): An advantage of decomposing before coding
Because Register User, Run Quiz and Show Leaderboard (and Run Quiz’s own three sub-modules) are now clearly separated, the developer can work out a sensible order to build them in. For example, Register User has to be working correctly before Run Quiz can be properly tested with a real registered user, and Show Leaderboard cannot be meaningfully tested until Run Quiz is producing real scores to display. [1]
This also means each module can be coded, tested and debugged on its own, rather than the developer only being able to test QuizMaster as one single, undivided program where a bug anywhere is much harder to isolate. [1]
Final answers
- (a) See the structure diagram above: QuizMaster → {Register User, Run Quiz, Show Leaderboard}; Run Quiz → {Ask Question, Mark Answer, Update Score}.
- (b) A structure diagram shows the hierarchy of modules (no order/decisions); a flowchart shows the step-by-step sequence of instructions, including decisions and loops.
- (c) It lets the developer plan a sensible build order and test/debug each module independently, rather than only being able to test the whole app as one piece.