levo

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.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

The three basic programming constructs are sequence, iteration and branching. What does each one do to the order in which statements run?

Key term

You are rewriting a count-controlled loop as a condition-controlled one. What three things must you supply, and which one do people forget?

Key term

Give two problems where recursion is the natural choice, and say why it suits them.

Key term

What is meant by the scope of a variable?

Key term

What is modularity, and give three real benefits of it.

Key term

What does passing a parameter by reference actually do?

Evaluation

What is the difference between a parameter and an argument?

Key term

What is an IDE, and what does it bring together in one place?

Evaluation

State the advantages of an object-oriented approach for a large program.

Key term

Decompose 'a system to run a school sports day' far enough to show what the modules would be.

Numbers

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?

Key term

What is backtracking?

Key term

Explain how backtracking places queens on a chessboard so that none attacks another, using a four-by-four board to show the undoing.

Key term

Give a worked example of data mining solving a real problem.

Key term

Antivirus software uses heuristic detection as well as signature matching. What is the difference, and what does the heuristic cost?

Evaluation

What are the limitations of performance modelling?

Process

Pipelining is not only a processor technique. Give an example of it applied elsewhere and say what is gained.

Key term

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. 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. 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. 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. 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. 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. 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.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Processors: Structure, Performance and Types
Input, Output and Storage
Systems Software
Applications Generation

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

If it matches, the search .
succeedsfailsrestarts

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

A0 + 0 gives 0.
B0 + 1 gives 1.
C1 + 1 gives 0 carry 1.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

A global variable means a variable reachable from anywhere in the program.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

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.