levo

Recursion, Sorting and Searching

Recursion

  • 3 things to know
  • A2 Unit 3
Start revising · £5/month

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.

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.

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

Cram the night before, weakest topic first

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

Fetch, , execute.
decodecompilestore

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.

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