levo

Theory of Computation

Procedural and Functional Abstraction

  • 2 things to know
  • Paper 1
Start revising · £5/month

Overview

Recall questions on what procedural abstraction is, worked examples of values being abstracted away, and why the result is a procedure.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What is procedural abstraction?

Key term

Why is a function easier to reason about than a procedure?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is procedural abstraction?

    Model answer

    Procedural abstraction strips out the particular values used in a computation. What is left is the computational pattern, or computational method — a procedure. Procedural abstraction therefore represents a computational method.

  2. 2

    Work through an example that shows the actual values being abstracted away.

    Model answer

    Start with three particular computations: 3 × 3, 7 × 7 and 12 × 12. Each uses its own actual value. Abstract that value away by replacing it with a name, and the shared pattern appears: PROCEDURE square(x) RETURN x * x ENDPROCEDURE The procedure captures the method — multiply the number by itself — without committing to any particular number. That step, from the specific computations to the general pattern, is procedural abstraction.

  3. 3

    Why is the result of procedural abstraction described as a procedure rather than a function?

    Model answer

    Because abstracting away the values leaves the method of computation still fully specified. square(x) says exactly how the answer is produced: multiply x by itself. A procedure is a stated way of computing something, so that is what you have. Getting a function, which says only what the relationship between input and output is and nothing about how it is worked out, requires a further abstraction on top of this one.

  4. 4

    What is functional abstraction?

    Model answer

    Functional abstraction is a further abstraction applied to a procedure, which disregards the particular computation method. The result is a function: something defined only by the relationship between what goes in and what comes out, with how the result is produced hidden.

  5. 5

    Explain the difference between procedural abstraction and functional abstraction, and why the second is needed.

    Model answer

    Treat it as two abstractions applied one after the other. The first strips the particular values out of a computation and leaves behind the method of computing — and a method is a procedure, not a function, because how the answer is worked out is still written into it. Only when that method is thrown away as well, by a second and further abstraction, is what remains a function: a bare mapping from inputs to outputs. That second step, functional abstraction, is needed because two procedures that sort a list by completely different methods describe one and the same function; without it you could neither say they were equivalent nor reason about what a program computes independently of how it computes it.

  6. 6

    Use square root to illustrate the step from a procedure to a function.

    Model answer

    A procedure for square root might state a method: start with a guess g for √x, repeatedly replace g by (g + x / g) / 2 until it stops changing, then return g. That is a computational method with the values abstracted away. Apply functional abstraction and the method is disregarded, leaving only sqrt: a mapping that takes a non-negative number and yields the number whose square it is. Written as a function, sqrt(9) = 3 tells you nothing about how the 3 was arrived at, and the underlying method could be replaced by a lookup table or by hardware without changing the function at all.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A driver is .
softwarehardwarestorage

Blank Blitz consolidates the facts

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

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

Head means the first single element of a non-empty list.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

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

Every question in Theory of Computation, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.