1/54
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is casting, and why is it often needed when handling user input?
Converting a value from one data type to another; it's often needed because user input is usually received as a string, but numerical comparisons or calculations require it to be cast to an integer or real number first
Name the three fundamental programming constructs used to control the flow of a program
Sequence (statements executed one after another), selection/branching (decision-making, e.g. if/else, switch/case), iteration (repeating instructions, e.g. for/while loops)
What is recursion?
A programming technique where a function calls itself to solve a problem, breaking it down into smaller instances of the same problem, rather than relying on iterative loops
Name the two essential features every recursive algorithm must have
A base case (a condition where it can return a value without making further recursive calls), and a mechanism that moves each call closer to that base case
*Why is a proper stopping condition (base case) essential in a recursive function?
Without one, the function will keep calling itself indefinitely, consuming increasing amounts of memory on the call stack, eventually causing a stack overflow error and crashing the program
Give one benefit and one drawback of using recursion instead of iteration
Benefit: can express certain problems (e.g. tree structures, fractals) more concisely and readably. Drawback: repeated function calls can be CPU and memory intensive, leading to slower execution and making the program harder to debug
Give one benefit and one drawback of using iteration instead of recursion
Benefit: generally more memory-efficient and performant, and easier to debug/understand. Drawback: can require more lines of code and become complex for problems that are naturally recursive in structure (e.g. traversing a tree)
*A programmer needs to calculate the factorial of a number — describe how recursion would solve this
The function calls itself with a smaller value each time (n multiplied by factorial(n-1)), until it reaches the base case (n == 0 or n == 1, which returns 1); the results are then multiplied together as the recursive calls return, building up the final factorial value
What is a global variable?
A variable declared at the outermost level of a program, outside any function or procedure, meaning it can be accessed and modified from anywhere in the program
Give one benefit and one drawback of using global variables
Benefit: only needs to be declared once and doesn't need to be passed as a parameter between modules, allowing easy data sharing. Drawback: remains in memory for the entire program's run and can make code harder to maintain/debug, since it's difficult to track where in the program the value is being changed
What is a local variable?
A variable declared within a specific scope, such as inside a function or code block; it can only be accessed within that block, and is destroyed once execution of the block ends
Give one benefit and one drawback of using local variables
Benefit: encapsulates data within its function/block, preventing unintended access from elsewhere in the program, and is memory-efficient since it's automatically destroyed when the block ends. Drawback: repeatedly creating and destroying local variables (e.g. inside a loop or recursive function) can add unnecessary memory overhead
*Why might using too many global variables make a large program difficult to maintain?
Because any part of the program can modify a global variable at any time, it becomes difficult to trace exactly where and why a variable's value has changed, making bugs harder to track down and the codebase harder to reason about
What is the difference between passing a parameter by value and by reference?
Passing by value sends a copy of the data to the subroutine, so changes inside the subroutine don't affect the original variable; passing by reference sends the actual memory location, so changes inside the subroutine do affect the original variable
Give one situation where passing by value is preferable, and one where passing by reference is preferable
By value is preferable when the original data must be protected from being altered by the subroutine (data protection). By reference is preferable when the subroutine needs to directly manipulate and update the original data, or when working with large data structures where copying would waste memory
What is an IDE (Integrated Development Environment)?
A software tool that provides programmers with a comprehensive platform to write, edit, compile, debug, and manage their code efficiently in one place
What does syntax highlighting in an IDE do, and why is it useful?
Assigns distinct colours/styles to keywords, strings, comments and variables; it helps programmers quickly identify and differentiate code components, reducing syntax errors and improving readability
What does autocomplete (code completion) in an IDE do?
Suggests code completions as the programmer types (e.g. variable/function names, or automatically closing brackets), reducing typing effort and preventing typos or naming inconsistencies
What does auto-indent in an IDE do?
Automatically indents code when starting a new line within a code block, making the structure of selection and iteration constructs visually clear
What is a breakpoint, and how is it used when debugging?
A marker set at a specific line of code that halts program execution when reached during runtime, allowing the developer to inspect the program's state and variable values at that exact point
What is a variable watch window used for?
A debugging tool that lets a developer monitor the value of specific variables as the program runs, helping them understand how those variables change over time and diagnose value-related bugs
What is stepping mode in an IDE?
A debugging mode allowing the developer to execute the program one line at a time (with options like step into/over/out), giving a granular view of execution to pinpoint exactly where a bug occurs
*A programmer is trying to work out why a loop variable has an unexpected value halfway through execution — which two IDE debugging features would help most, and why?
A breakpoint set inside the loop (to pause execution at that point) combined with a variable watch window (to observe the variable's value change on each iteration), letting the programmer see exactly when and where the value diverges from what's expected
What are computational methods, in the context of A-level Computer Science?
Problem-solving techniques that use algorithms and mathematical models to analyse, simulate, and solve complex problems efficiently using a computer
What real-world constraints can affect whether a theoretically solvable problem is practical to solve computationally?
Practical limitations such as available computing power, processing speed, and memory — a problem may be solvable in principle but impractical given the resources actually available (e.g. running a complex machine learning model on a basic laptop)
*Give an example of a business problem that is NOT well suited to a computational solution, and explain why
High staff turnover due to low morale — the root causes are typically cultural or managerial (e.g. unrealistic targets, poor support, work-life balance) rather than something an algorithm can directly fix, even though software might help gather data on the problem
What is problem recognition?
The process of determining whether there is genuinely a problem that needs solving, and precisely identifying what that problem actually is, before attempting to design a solution
What is problem decomposition, and what four things does it help programmers do?
Breaking a big problem down into smaller, independently solvable sub-problems; it helps break the problem down, identify the steps/processes involved, identify reusable components, and split tasks between programmers/teams
What is the divide and conquer strategy, and name its three steps?
A strategy for making a complex task easier by breaking it into smaller, manageable parts; its three steps are Divide (break the problem into sub-problems), Conquer (solve each sub-problem independently), Combine (merge the sub-solutions into the overall solution)
Give one benefit and one drawback of the divide and conquer strategy
Benefit: can make programs more time-efficient and make effective use of cache memory, since sub-problems are smaller. Drawback: not all problems can be broken down and solved independently, and if implemented recursively it can risk stack overflow
What is task parallelism?
When several tasks or sub-tasks (often produced by dividing a problem) are carried out concurrently/simultaneously to speed up overall completion time
How does abstraction support problem decomposition when designing a solution?
Applying abstraction first removes non-essential details (e.g. a system's colour scheme) so the programmer can focus purely on the critical aspects needed to solve the problem (e.g. server response time, database query efficiency), before decomposing it further
What is backtracking?
An algorithmic approach that builds a solution incrementally, exploring a path until it reaches a dead end, then retreating (backtracking) to the last decision point to try a different path instead
Give one advantage and one limitation of backtracking
Advantage: guarantees a solution will be found if one exists, and is relatively straightforward to implement. Limitation: can be slow for large or complex problems, and doesn't necessarily find the best/most efficient solution, only a valid one
*Why is backtracking well suited to solving a maze?
Because it can explore a path step by step, and when it hits a dead end it retreats to the last unexplored branching point to try a different route, systematically covering all possibilities until it reaches the exit
What is data mining?
The process of analysing large quantities of data using algorithms and statistical methods to extract useful information and identify patterns or relationships that are not immediately obvious to people
Give one benefit and one drawback of data mining
Benefit: can identify patterns/trends humans might miss and help organisations make better predictions. Drawback: requires powerful computers with significant processing power, and inaccurate input data will produce inaccurate/misleading results
Give one real-world industry example of data mining in use
Any one of: retail (personalised product recommendations based on purchase history), healthcare (predicting disease outbreaks/patient admissions), finance (flagging fraudulent transactions), automotive (predicting vehicle part failure), entertainment (content recommendations based on viewing history)
What are heuristics, in the context of problem solving?
Using experience, "rules of thumb" and educated guesses to find a solution to a problem more quickly than exhaustive/traditional methods, prioritising speed over guaranteed accuracy
What is meant by getting "stuck in a local optimum" when using a heuristic method?
When a heuristic algorithm settles on a solution that appears good based on the immediate feedback it has, but is not actually the best possible solution overall, similar to a searcher in "Hot and Cold" stopping at a spot that seems "hot" but isn't the actual target
Give one benefit and one drawback of using heuristic methods
Benefit: saves time, since not every possibility needs to be investigated to reach a usable answer. Drawback: does not guarantee finding the optimal solution, only one that is "good enough," and incorrect heuristic values can lead to inaccurate results
Give an example of an algorithm that uses heuristics
The A* algorithm, used in pathfinding and graph traversal, which uses heuristics to find a path quickly, though the path found may not always be the most efficient one possible
What is performance modelling?
Testing or simulating the behaviour of a system before it is used in the real world, to evaluate and predict its performance characteristics under different conditions
Give one benefit and one drawback of performance modelling
Benefit: allows developers to predict and address problems (e.g. bottlenecks) before they affect real users, e.g. through stress testing under heavy load. Drawback: results are only as accurate as the data and rules fed into the model — if these are wrong, the model's predictions will be incorrect
Give one real-world example of performance modelling in use
Any one of: database optimisation (simulating different architectures/indexing strategies), caching strategy design (modelling hit/miss ratios), energy efficiency (estimating power consumption for battery-powered devices)
What is pipelining, as a computational method?
Carrying out multiple instructions or tasks concurrently, where the output of one stage becomes the input to the next, improving overall efficiency compared to completing each task fully before starting the next
Describe the three stages involved in applying pipelining to a task
1) Break down the task into its individual component tasks. 2) Arrange these tasks into a logical sequential order. 3) Allow multiple tasks to operate concurrently rather than waiting for each to fully finish before the next begins
*Give an example of pipelining used outside of the CPU, in either a real-world process or in code
Any valid example, e.g. a car manufacturing process where the engine and chassis can be developed simultaneously once designs are drawn, while other steps like painting must happen in a fixed order after the body is created; or in Unix, chaining commands using the | symbol so the output of one command becomes the input of the next
What is visualisation, as a computational method?
Presenting data or concepts in a simpler, often graphical form, to make complex systems or data easier for humans to understand
Give one benefit and one drawback of visualisation
Benefit: can make it easier to spot new trends and patterns that might not otherwise be noticed, and simplifies complex concepts. Drawback: it cannot explain why something is the way it is, and different people may interpret the same visualisation differently
Give three examples of visualisation techniques used in computing
Any three of: flowcharts (mapping out workflows/processes), UML diagrams (visualising a system's architecture and how classes/objects interact), wireframes (low-fidelity layout plans for a program or website)
*When solving a problem in an object-oriented language, why might a programmer choose to model real-world entities as classes rather than using separate variables and procedural functions?
Classes group related data (attributes) and behaviour (methods) together into a single reusable structure, making the code easier to organise, extend, and maintain as the problem grows, and letting the program's structure closely mirror the real-world entities it's modelling
*A program needs to handle several different types of vehicle (car, motorcycle, van), each with slightly different behaviour for a "move" action — how could inheritance and polymorphism be used to solve this cleanly?
A base Vehicle class could define a general move() method, with Car, Motorcycle and Van as subclasses that inherit from it and override move() with their own specific implementation; code that calls move() on a Vehicle reference then automatically runs the correct version for whichever subclass object it actually is
Why is it useful to plan an algorithm using pseudocode or a flowchart before writing it in a specific programming language?
It lets the logic and decision points of the solution be worked out and checked independently of any one language's exact syntax, making it easier to spot design flaws early and to later implement the same logic in whichever language is most appropriate
Why might a large team of developers use top-down design and decomposition when building a substantial piece of software?
Breaking the problem into smaller, well-defined sub-problems allows different developers to work on separate self-contained modules in parallel, makes each part easier to test and maintain independently, and allows components to be reused rather than rewritten