WJEC A-Level Computer Science 601-5345-3
Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types
Data Structures
Organisation of Data: Files and Records
Database Systems
The Operating System
Algorithms and Programs
Principles of Programming
Systems Analysis
Software Engineering and Program Construction
Types of Software System
Practical Programming
Data Security and Integrity
Computing, Society and the Law
Advanced Data Structures and Logic
Recursion, Sorting and Searching
Programming Paradigms and Translators
System Design and Human-Computer Interaction
Software Engineering Tools and Professional Practice
Advanced Architecture and Assembly Language
Communication Networks and File Organisation
Number Representation and Floating Point
Databases and Distributed Systems
Operating System Management
Software Systems and Applications
Data Security, Cryptography and Attack
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.
What is a recursive algorithm?
What happens when a recursive routine is written without a base case?
Questions from this subtopic
Each one with the model answer underneath.
- 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
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
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
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
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
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.
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.