levo

Theory of Computation

Procedural and Functional Abstraction

  • 2 things to know
  • Paper 1

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.

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.

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

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.

A driver is .
softwarehardwarestorage

Blank Blitz makes facts automatic

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

AThe integer 5 is 0101.
B0.75 is 1/2 + 1/4.
CThe fraction bits are 1100.

Build It gets the exam shape right

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

Head means the first single element of a non-empty list.
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.

Every question in Theory of Computation, 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.