levo

Recursion, Sorting and Searching

Recursion

  • 3 things to know
  • A2 Unit 3

Overview

Recursive algorithm, factorial function recursively and fibonacci sequence recursively.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why can a recursive solution fail on a large input where an iterative one succeeds?

Key term

What is a recursive algorithm?

Key term

What happens when a recursive routine is written without a base case?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a recursive algorithm?

    Model answer

    A recursive algorithm is one that solves a problem by calling itself on a smaller version of the same problem.

  2. 2

    Name the two parts every recursive definition must have.

    Model answer

    It must have a base case that is answered without any further call, and a general case that calls the routine again on a smaller problem.

  3. 3

    What happens when a recursive routine is written without a base case?

    Model answer

    The calls never stop, so the stack keeps growing until the memory reserved for it is exhausted and the program crashes.

  4. 4

    Which data structure supports recursion while a program runs, and what is stored on it?

    Model answer

    A stack supports it, holding one frame for each unfinished call containing that call's return address, parameters and local variables.

  5. 5

    Define the factorial function recursively.

    Model answer

    The factorial of 1 is 1, and the factorial of any n greater than 1 is n multiplied by the factorial of n − 1.

  6. 6

    A recursive factorial routine with a base case of 1 is asked for the factorial of 5. How many times is the routine entered, and what value is returned?

    Model answer

    It is entered five times, for 5, 4, 3, 2 and 1, and it returns 120.

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.

Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types

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.

Fetch, , execute.
decodecompilestore

Blank Blitz makes facts automatic

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

AEncryption is reversible.
BThe stored form could be decrypted.
CA hash cannot be reversed.

Build It gets the exam shape right

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

A bit is a single binary digit.
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 Recursion, Sorting and Searching, 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.