Save
A-level Computer Science
School Notes
Recursion and Programming
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Ana Saker
Visit profile
Cards (30)
What is a global variable?
Visible throughout a
program
View source
What is a local variable?
Visible only in its
module
View source
Why are global variables sometimes used?
To access the same value from
various
parts
View source
Why is it good practice to avoid global variables?
They increase
program
complexity and conflicts
View source
What does branching/selection do in programming?
Decides
which
code
is
run
View source
What is iteration in programming?
Repeatedly
runs
the
same
code
View source
What is sequence in programming?
Instructions
performed
one after another
View source
What are the differences between a procedure and a function?
A function returns a single value.
A procedure does not return a value.
A function is part of an
expression
.
A procedure is an instruction/statement.
View source
What happens when a procedure is called?
The code in the procedure
executes
View source
What is parameter passing by value?
Uses a
local copy
of the data
View source
What is parameter passing by reference?
Memory location of data
is sent
View source
What are the habits for writing good functions?
No longer than a
single
page of code.
Variable identifiers must conform to a standard.
Each function must have a single
entry point
.
Variables must not be set up outside the function's
scope
.
View source
What is a stack in programming?
LIFO
data structure
View source
What is a queue in programming?
FIFO
data structure
View source
How does a stack operate?
Data is
popped
/
pushed
from the
top
View source
How does a queue operate?
Data is
dequeued
from the front
View source
What is an array?
Fixed size
data structure
View source
What is a list in programming?
Dynamic
size
data structure
View source
What is a tuple?
Immutable
data structure
with multiple types
View source
What is a linked list?
Ordered set of
data elements
linked together
View source
What is a tree in programming?
Hierarchical structure with
nodes
View source
What is the root node in a tree?
The topmost node in the
hierarchy
View source
What are leaf nodes in a tree?
Nodes without any lower
nodes
View source
How do you search a binary tree?
Check
root
, then
left
or right subtree
View source
What is a recursive algorithm?
One that calls
itself
View source
What is the factorial of 5?
120
120
120
View source
What is the base case in recursion?
Condition
that stops the recursion
View source
What is the advantage of iteration over recursion?
Uses fewer
variables
and memory
View source
Why does recursion use more memory than iteration?
Each call stores state on the
stack
View source
What are the advantages of recursion over iteration?
Expresses problems naturally.
Simplifies complex problems.
Easier to implement for certain
algorithms
.
View source