OCR A-Level Computer Science H446
Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation
Software Development
Types of Programming Language
Exchanging Data
Networks
Web Technologies
Data Types and Number Representation
Data Structures
Boolean Algebra
Legal, Moral, Cultural and Ethical Issues
Elements of Computational Thinking
Problem Solving and Programming
Algorithms
Problem Solving and Programming
- 10 subtopics
- 18 things to know
- Component 02
What Problem Solving and Programming covers
Problem Solving and Programming is examined on component 02 of OCR Computer Science, Algorithms and programming. 119 recall questions across 10 subtopics.
Where it is assessed
Component 02
Algorithms and programming, the whole of the second paper.
Check the OCR specification ↗The 10 subtopics
Each one has its own page.
- Programming techniques: Programming constructsRecall questions on sequence, branching and iteration, count-controlled and condition-controlled loops, tracing and nested loops, infinite loops, elseif order and switch/case, plus reading and writing text files, string length and substrings, and the MOD, DIV and ^ operators.Open →
- Programming techniques: RecursionRecall questions on recursive subroutines, base and general cases, tracing factorial calls, the call stack and unwinding, stack overflow, recursion depth on large data, recursion compared with iteration, and slow recursive Fibonacci.Open →
- Programming techniques: Global and local variablesRecall questions on the scope and lifetime of variables, local and global variables, predicting output when a local variable shadows a global one, why globals are discouraged and when they are justified, and fixing out-of-scope values.Open →
- Programming techniques: modularity, functions and procedures, and parameter passingRecall questions on modularity and its benefits, functions and procedures, what a caller needs to know, reusable subroutines, side effects, passing parameters by value and by reference with traces, returning two results, and parameters versus arguments.Open →
- Programming techniques: Use of an IDE to develop/debug a programRecall questions on integrated development environments, breakpoints, stepping into and over, watch windows, the call stack view, syntax and error highlighting, auto-completion, refactoring tools, and debugging logic errors and stack overflows.Open →
- Programming techniques: Use of object oriented techniquesRecall questions on classes and objects, attributes and methods, constructors, separate object state, encapsulation with private attributes and get and set methods, inheritance and superclass constructors, polymorphism, and when object-oriented design fits.Open →
- Computational methods: solvable problems, problem recognition, decomposition, and divide and conquerRecall questions on features that make a problem solvable or unsolvable by computational methods, problem recognition, problem decomposition, divide and conquer, binary search comparisons, and algorithms that divide and combine.Open →
- Computational methods: Use of abstraction and backtrackingRecall questions on abstraction in computational solutions and the danger of abstracting too much, abstraction with decomposition, backtracking in mazes and the four queens problem, its limitations, and problems that suit backtracking.Open →
- Computational methods: data mining, heuristics and performance modellingRecall questions on data mining and its limitations, heuristics in route planning, satnavs and antivirus detection, what heuristics trade away, performance modelling with worked examples, and when modelling is the only sensible option.Open →
- Computational methods: pipelining, visualisation and choosing a methodRecall questions on pipelining outside the processor and what limits it, visualisation and its limitations, backtracking compared with heuristics, choosing the computational method that fits a problem, and combining methods in a satnav.Open →
What you need to know
Answer each one before you reveal it.
You are rewriting a count-controlled loop as a condition-controlled one. What three things must you supply, and which one do people forget?
Give two problems where recursion is the natural choice, and say why it suits them.
What is meant by the scope of a variable?
What is modularity, and give three real benefits of it.
What does passing a parameter by reference actually do?
What is the difference between a parameter and an argument?
What is an IDE, and what does it bring together in one place?
State the advantages of an object-oriented approach for a large program.
Decompose 'a system to run a school sports day' far enough to show what the modules would be.
A sorted list holds 1,000,000 records. Roughly how many comparisons does a binary search need in the worst case, and what does that show?
What is backtracking?
Explain how backtracking places queens on a chessboard so that none attacks another, using a four-by-four board to show the undoing.
Give a worked example of data mining solving a real problem.
Antivirus software uses heuristic detection as well as signature matching. What is the difference, and what does the heuristic cost?
What are the limitations of performance modelling?
Pipelining is not only a processor technique. Give an example of it applied elsewhere and say what is gained.
Give a worked application of visualisation.
Take Problem Solving and Programming further
The same content, four other ways.
Commonly confused
Pairs that lose marks when they are blurred together.
Backtracking vs A heuristic
Backtracking: returning to the last choice point when a path fails, and trying the next option. A heuristic: a rule of thumb that finds a good enough answer without guaranteeing the best one.
Performance modelling vs Visualisation
Performance modelling: predicting how a system will behave under load without building and running it. Visualisation: presenting data graphically so that patterns a table would hide become visible.
A global variable vs A local variable
A global variable: a variable reachable from anywhere in the program. A local variable: a variable reachable only inside the block or subroutine where it was declared.
Questions from this topic
Each one with the model answer underneath.
- 1
The three basic programming constructs are sequence, iteration and branching. What does each one do to the order in which statements run?
Model answer
Sequence: statements are carried out one after another in the order they are written, each exactly once. Branching (selection): a Boolean condition is tested and the program takes one of two or more alternative paths, so some statements are skipped altogether. Iteration: a block of statements is repeated, either a set number of times or until a condition changes. Every algorithm can be built from these three constructs alone.
- 2
Work through this and say what is printed, then explain why the order of the lines matters. price = 20 total = price * 3 price = 5 print(total)
Model answer
It prints 60. total was worked out while price still held 20, and assigning 5 to price afterwards does not re-run that calculation. In a sequence each line uses the values that exist at the moment it runs, so moving price = 5 above the calculation would make the program print 15 instead. This is why sequence is a construct in its own right: the same three statements in a different order give a different result.
- 3
Explain the difference between count-controlled and condition-controlled iteration, and give a situation that suits each.
Model answer
Count-controlled iteration repeats a fixed number of times that is known before the loop starts, using a counter that is stepped each time round (for example, for i = 1 to 10). It suits work where you already know how many repetitions are needed: processing every element of an array of 50 records, printing a times table, drawing a shape with a known number of sides. Condition-controlled iteration repeats while, or until, a condition holds, so the number of repetitions is not known in advance. It suits validating input until the user types something acceptable, reading lines until the end of a file is reached, or a game loop that runs until the player quits.
- 4
A loop is written as for i = 0 to 7. How many times does the body run, and why is this a classic place for an off-by-one error?
Model answer
Eight times, with i taking the values 0, 1, 2, 3, 4, 5, 6 and 7, because both end values are included. It is a classic error because someone reading it as 'up to 7' may expect seven repetitions. It is also where array indexing catches people out: arrays here are numbered from 0, so an array of eight items has its last item at index 7 and this loop is exactly right for it, whereas for i = 0 to 8 would run nine times and try to read an item that does not exist.
- 5
What is the one behavioural difference between a while loop and a do ... until loop, and when does it matter?
Model answer
A while loop tests its condition before the body, so if the condition is false at the very start the body never runs at all. A do ... until loop tests after the body, so the body always runs at least once. It matters whenever running the body once with no valid data would be wrong. 'While there are records left, process one' must be a while loop, because an empty file should cause no processing. 'Ask for a password and repeat until it is correct' suits do ... until, because you have to ask at least once before there is anything to test.
- 6
Trace this and give the two numbers printed. count = 0 total = 0 while total < 20 count = count + 1 total = total + count endwhile print(count) print(total)
Model answer
It prints 6 then 21. Working through: count 1 gives total 1; count 2 gives total 3; count 3 gives total 6; count 4 gives total 10; count 5 gives total 15 — still under 20, so the loop runs once more; count 6 gives total 21, the condition total < 20 is now false and the loop ends. Note that the loop finishes with total past 20 rather than exactly on it, because the test only happens between whole repetitions.
What is inside Levo
Six ways to work the same material.
Problem Solving and Programming revision questions
- What does Problem Solving and Programming cover in OCR A-Level Computer Science?
- 10 subtopics: programming techniques: programming constructs, programming techniques: recursion, programming techniques: global and local variables, programming techniques: modularity, functions and procedures, and parameter passing, programming techniques: use of an ide to develop/debug a program, programming techniques: use of object oriented techniques, computational methods: solvable problems, problem recognition, decomposition, and divide and conquer, computational methods: use of abstraction and backtracking, computational methods: data mining, heuristics and performance modelling and computational methods: pipelining, visualisation and choosing a method. Each one has its own page with questions and model answers.
- How is Problem Solving and Programming organised?
- By the OCR H446 specification, subtopic by subtopic, so it matches the order you are taught it in.
Every question in Problem Solving and Programming, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.