{"base":{"id":"cs10-08","subject":"Algorithms","title":"From a problem to an algorithm","scene":"code10","steps":[{"mode":"ipo","eyebrow":"Inputs, process, outputs","title":"What goes in, what comes out?","body":"Before writing any code, work out the inputs (data going in), the process (what happens to it) and the outputs (results). Explore a cinema ticket machine.","actions":[{"id":"i","label":"Inputs"},{"id":"p","label":"Process"},{"id":"o","label":"Outputs"}]},{"mode":"decomp","eyebrow":"Decomposition","title":"Break the problem down","body":"Big problems are easier when you split them into smaller sub-problems, then split those again. Each small piece can be solved, coded and tested on its own.","actions":[{"id":"split","label":"Split it further"}]},{"mode":"symbols","eyebrow":"Flowchart symbols","title":"Four shapes","body":"A flowchart shows an algorithm as shapes joined by arrows. Each shape has a job: start and stop, input and output, process, and decision. Tap each one.","actions":[{"id":"s0","label":"Terminator"},{"id":"s1","label":"Input / output"},{"id":"s2","label":"Process"},{"id":"s3","label":"Decision"}]},{"mode":"flow","eyebrow":"Flowcharts","title":"Follow the arrows","body":"This flowchart sets a ticket price: children under 12 pay $2, people 65 and over pay $1, others $3. Change the age and follow the highlighted route.","controls":[{"id":"age","label":"Age","min":1,"max":90,"step":1,"value":30}]},{"mode":"pseudo","eyebrow":"Pseudocode","title":"The same algorithm in words","body":"Pseudocode writes an algorithm in structured English that any programmer can turn into code. Compare it line by line with Python as you change the age.","controls":[{"id":"age","label":"Age","min":1,"max":90,"step":1,"value":30}]},{"mode":"quiz","look":"symbols","eyebrow":"Check yourself","title":"Pick the symbol","body":"In a login flowchart, the next step asks: 'Is the password correct?'","question":"Which flowchart symbol should you use?","options":["Rectangle","Diamond","Parallelogram"],"answer":1,"right":"Correct. A Yes/No question is a decision, drawn as a diamond with two exits.","wrong":"Not quite. This step asks a question with two possible answers."}],"more":[{"type":"cards","id":"worked","eyebrow":"Worked examples","title":"From problem to pseudocode","intro":"Each example goes: understand → inputs/outputs → steps → pseudocode.","items":[{"tag":"Example","title":"Average of three test marks","body":"INPUT  Mark1, Mark2, Mark3\nTotal ← Mark1 + Mark2 + Mark3\nAverage ← Total / 3\nOUTPUT Average","code":true},{"tag":"Example","title":"Is a number positive, negative or zero?","body":"INPUT Number\nIF Number > 0\n  THEN OUTPUT \"Positive\"\n  ELSE IF Number < 0\n    THEN OUTPUT \"Negative\"\n    ELSE OUTPUT \"Zero\"\n  ENDIF\nENDIF","code":true},{"tag":"Example","title":"Keep asking until the PIN is right","body":"REPEAT\n  INPUT Pin\nUNTIL Pin = 4821\nOUTPUT \"Unlocked\"","code":true},{"tag":"Python","title":"The ticket algorithm in Python","body":"age = int(input(\"Age? \"))\nif age < 12:\n    price = 2\nelif age >= 65:\n    price = 1\nelse:\n    price = 3\nprint(\"Price: $\", price)","code":true}]},{"type":"cards","id":"mistakes","eyebrow":"Common mistakes","title":"Watch out for these","items":[{"tag":"Mistake","title":"A decision with one exit","body":"Every diamond needs two labelled arrows: Yes and No (or True and False)."},{"tag":"Mistake","title":"Using a rectangle for input","body":"Input and output use a parallelogram. Rectangles are for processes like calculations."},{"tag":"Mistake","title":"Arrows that go nowhere","body":"Every path must lead to Stop. Trace each route with your finger to check."},{"tag":"Mistake","title":"Vague steps","body":"'Work out the price' is too vague. Say exactly how: 'IF Age < 12 THEN Price ← 2'."}]},{"type":"cards","id":"method","eyebrow":"Set out your answer","title":"Writing pseudocode in tests","items":[{"tag":"Keywords","title":"Use capitals for keywords","body":"INPUT, OUTPUT, IF, THEN, ELSE, ENDIF, WHILE, ENDWHILE, FOR, NEXT, REPEAT, UNTIL. Use ← for assignment."},{"tag":"Indent","title":"Show the structure","body":"Indent the lines inside IF, loops and CASE so the reader can see what belongs where."},{"tag":"Check","title":"Dry run it","body":"Pick test values and walk through your algorithm line by line before you hand it in."}]},{"type":"bars","id":"three","eyebrow":"Data","title":"The three building blocks","intro":"Every algorithm ever written uses just these three structures.","items":[{"label":"Sequence","value":100,"display":"steps in order","color":"#2f6fdb"},{"label":"Selection","value":100,"display":"choosing a path (IF, CASE)","color":"#7c3aed"},{"label":"Iteration","value":100,"display":"repeating (FOR, WHILE, REPEAT)","color":"#1f9d55"}],"facts":[{"title":"Abstraction","body":"Abstraction means hiding detail that doesn't matter. A train map shows stations and lines, not the exact curves of the track: perfect for planning a journey."},{"title":"Algorithm vs program","body":"An algorithm is the plan: a set of steps to solve a problem. A program is that plan written in a language a computer can run."}]},{"type":"cards","id":"deeper","eyebrow":"Go deeper","title":"More than the lesson","items":[{"tag":"History","title":"Where 'algorithm' comes from","body":"The word comes from the name of al-Khwarizmi, the 9th-century Baghdad mathematician whose books explained step-by-step methods for calculating. Translated into Latin as 'Algoritmi', his name became our word."},{"tag":"Real world","title":"Algorithms you use every day","body":"Route planners find the quickest way home, music apps choose the next song, and spam filters decide which emails to hide. Each one started as decomposition and a flowchart on a whiteboard."},{"tag":"Careers","title":"Who designs algorithms?","body":"Software engineers, systems analysts (who study a problem and design the solution before coding), data scientists and game designers all start by decomposing problems and drawing flowcharts."},{"tag":"Coming next","title":"Where this leads","body":"Next: loops that count and total, then tracing algorithms with trace tables to find errors before they happen."}]},{"type":"cards","id":"challenge","eyebrow":"Challenge yourself","title":"Stretch your brain","intro":"Try each one before opening the card.","items":[{"tag":"Challenge","title":"Write pseudocode that outputs the larger of two numbers, or 'Equal'","body":"INPUT A, B\nIF A > B\n  THEN OUTPUT A\n  ELSE IF B > A\n    THEN OUTPUT B\n    ELSE OUTPUT \"Equal\"\n  ENDIF\nENDIF","code":true},{"tag":"Challenge","title":"Decompose 'make a school timetable app' into four sub-problems","body":"One good answer:\n1. Store the lessons, teachers and rooms.\n2. Let students choose subjects.\n3. Check for clashes (one teacher or room in two places).\n4. Display each student's week.\nEach can be broken down again, for example 3 → compare times, flag clashes, suggest fixes."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Algorithms in daily life","items":[{"title":"Flowchart your morning","time":"20 minutes","need":["Paper and pens"],"steps":["List everything you do from waking up to leaving home.","Add at least two decisions, like 'Is it raining?'.","Draw it as a flowchart with the correct shapes.","Ask someone to follow it exactly. Where did it go wrong?"],"why":"Following an algorithm exactly shows up missing steps and unclear decisions, the same way a computer would.","safety":"No safety risks."},{"title":"Precise instructions game","time":"15 minutes","need":["A partner","Paper","A simple drawing"],"steps":["Look at a simple drawing your partner can't see.","Give step-by-step instructions to reproduce it.","Your partner must follow them exactly, nothing more.","Compare the drawings and improve your instructions."],"why":"Computers need precise, unambiguous instructions. Vague steps like 'draw a shape near the top' cause errors.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Eight more questions","questions":[{"question":"What is decomposition?","options":["Breaking a problem into smaller parts","Removing unnecessary detail","Finding errors in code"],"answer":0,"right":"Correct. Smaller parts are easier to solve.","wrong":"Not quite. Think of taking something apart."},{"question":"Which flowchart symbol is used for 'OUTPUT total'?","options":["Rectangle","Parallelogram","Oval"],"answer":1,"right":"Correct. Input and output use a parallelogram.","wrong":"Not quite. Input and output have their own shape."},{"question":"What is abstraction?","options":["Repeating steps","Writing code","Hiding unnecessary detail"],"answer":2,"right":"Correct. Like a map that shows only what you need.","wrong":"Not quite. Think of a simplified map."},{"question":"In pseudocode, what does Total ← Total + 5 do?","options":["Adds 5 to Total","Compares Total with Total + 5","Outputs Total + 5"],"answer":0,"right":"Correct. ← means assignment.","wrong":"Not quite. The arrow stores a value."},{"question":"Which shape starts and ends a flowchart?","options":["Diamond","Terminator (rounded)","Rectangle"],"answer":1,"right":"Correct. Rounded ends say Start and Stop.","wrong":"Not quite. It has rounded ends."},{"question":"In the ticket flowchart, what does a 70-year-old pay?","options":["$3","$2","$1"],"answer":2,"right":"Correct. 70 is not under 12, but it is 65 or over.","wrong":"Not quite. Follow both decisions in order."},{"question":"What are the three basic programming structures?","options":["Sequence, selection, iteration","Input, output, storage","Flowcharts, pseudocode, code"],"answer":0,"right":"Correct. Every algorithm combines these.","wrong":"Not quite. They describe how steps are organised."},{"question":"In 'calculate the average of 3 marks', what is the output?","options":["The 3 marks","The average","The total"],"answer":1,"right":"Correct. The marks are inputs; the average is the result.","wrong":"Not quite. What does the user get back?"}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can…","items":["identify the inputs, processes and outputs of a system","decompose a problem into sub-problems","explain abstraction with an example","name and draw the four flowchart symbols","follow a flowchart for given inputs","draw a flowchart with a decision","write pseudocode using INPUT, OUTPUT, ← and IF","convert between a flowchart, pseudocode and Python"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"algorithm","meaning":"A set of step-by-step instructions to solve a problem."},{"word":"decomposition","meaning":"Breaking a problem into smaller sub-problems."},{"word":"abstraction","meaning":"Hiding details that are not needed."},{"word":"flowchart","meaning":"A diagram of an algorithm using shapes and arrows."},{"word":"pseudocode","meaning":"Structured English for writing algorithms."},{"word":"terminator","meaning":"The rounded Start/Stop symbol."},{"word":"process","meaning":"A step that does something, drawn as a rectangle."},{"word":"decision","meaning":"A Yes/No question, drawn as a diamond."},{"word":"sequence","meaning":"Steps carried out in order."},{"word":"selection","meaning":"Choosing between paths."},{"word":"iteration","meaning":"Repeating steps."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize, GCSE Computer Science: Algorithms, decomposition and abstraction","MacTutor History of Mathematics: al-Khwarizmi","Isaac Computer Science: Flowcharts and pseudocode","Python documentation: control flow tools"]}]},"overlay":null}