Mock Revision Flashcards
What is abstraction?
Abstraction is the process of removing excessive details to arrive at a
representation of a problem that consists of only the key features.
What is representational abstraction?
Analysing what is relevant to a given scenario and simplifying a problem based on this information.
What is abstraction by generalisation?
Categorising certain problems as being of a particular type, then using common solutions to solve them.
What is data abstraction?
When details about how data is stored are hidden, so programmers can make use of abstract data structures without knowing how they are implemented.
What is procedural abstraction?
When programmers can perform functions without having any knowledge about the code used to implement the functionality.
What do very large, complex problems use?
They use multiple levels of abstraction, with each level performing a different role. The highest levels are closest to the user and provide an interface to interact with, and the lowest levels are responsible for performing these tasks through the execution of machine code.
Why is abstraction good in a system?
It allows non-experts to make use of it by hiding information that is too complex or irrelevant to it’s purpose.
Why is abstraction good in software?
It enables more efficient design, as programmers don’t have to worry about unnecessary details. This reduces the time needing to be spent on the project and prevents the program getting unnecessarily large.
What is caching?
Caching is the process of storing instructions or values in cache memory after usage, as they may be used again. This saves time which would have otherwise needed to be used to store and retrieve the instructions from secondary storage again.
What is prefetching?
A more advanced version of caching, in which algorithms predict which instructions will soon be fetched. These are then loaded and stored in cache before being fetched, meaning less time is spent waiting for them to be loaded from the hard disk.
What is the limitation to prefetching?
The accuracy of the algorithms used, as they can only provide an informed prediction as to which instructions will be used, not a guarantee.
What is the limitation to caching?
How well a caching algorithm is able to manage the cache. Larger caches take a long time to search, so cache size limits how much data can be stored.
Give 3 examples of reusable components.
Implementations of abstract data structures, classes and subroutines.
Why are reusable components good?
More reliable, as they have already been tested and bugs dealt with.
This saves time, money and resources.
It also means they can be reused in future projects, saving further costs.
Why can reusable components be bad?
It may not always be possible to integrate existing components by third parties, because of compatibility issues with the rest of the software.
This means that the components need to be modified to work with the rest of the software, which can sometimes be more time-consuming than developing them in house.
What is problem decomposition?
Continually breaking down a large, complex problem into smaller subproblems which can be solved more easily.
Why is problem decomposition good?
Problems divided into sections become more feasible to manage and can be divided by a group of people according to the individuals’ skillsets.
Why is problem decomposition good?
Problems divided into sections become more feasible to manage and can be divided by a group of people according to the individuals’ skillsets.
How are problems commonly decomposed?
Top down design, also known as stepwise refinement.
Higher levels provide an overview, while lower levels specify in detail the components.
What is the aim of using top down design?
To keep splitting problems into subproblems until each problem can be represented as a self-contained module/subroutine. This can then be developed and tested separately before being integrated together.
Key part of identifying the components of a solution
Identifying tasks which could be solved using an already existing module, subroutine or library.
What are two of the most important decisions made within software development?
What programming paradigm to use, and how different pieces of information are collected.
What does sequence mean?
Code is executed line-by-line, from top to bottom
What does branching mean?
A certain code block is run if a specific condition is met, using IF statements. Also known as selection.
What does iteration mean?
A block of code is executed a certain number of times or while a condition is met. Using for, while or repeat until loops.
What is count controlled iteration?
Iteration is repeated a given number of times
What is condition controlled iteration?
Iteration continues until a given condition is met.
What is recursion?
A programming construct in which a subroutine calls itself during its execution, until a stopping condition is met, when the recursion stops. Produces same result as iteration.
What is the advantage of using recursion for certain problems?
They can be represented in fewer lines of code, making them less error-prone.
How does recursion work?
When the function calls itself, a new stack frame is create within the call stack, where parameters, local variables and return addresses are stored. This allows the subroutine to return to that point during its execution. Keeps going till the base case is reached, when the subroutine unwinds and pops the information off the stack.
What are two disadvantages to recursion?
Inefficient use of memory - if it calls itself too many times, danger of a stack overflow, when a call stack runs out of memory causing a crash.
Also difficult to trace, with more and more function calls.
What is tail recursion.
A form of recursion which is implemented in a more efficient way, in which less stack space is required.
What does scope refer to?
The section of code in which a variable is available.
What is the scope of a local variable?
Limited, meaning they can only be accessed within the block of code in which they were defined. If defined within a subroutine, can only be accessed within that subroutine.
Why are local variables good?
Multiple local variables with the same name can exist in different subroutines and remain unaffected by each other. Ensures subroutines are self-contained, with no danger of variables affected by code outside the subroutine.
What is the scope of a global variable?
Accessible across the whole program. All variables in the main body of a program are declared to be this, so useful for values that need to be used my multiple program parts.
Why is using global variables not recommended?
They can be unintentionally overwritten and edited.
They require more memory, because they aren’t deleted till the program terminates.
What happens if a local variable exists within a subroutine with the same name as a global variable?
The local variable will take precedence.
What is modular programming?
Talk about decomposition.
Compare procedures and functions?
Both named blocks of code that perform a specific tasks. Procedures don’t have to return a value, but can return multiple. Functions return one single value. Procedures typically given data as parameters while functions make use of local variables.
What does passing by value mean?
A parameter is treated as a local variable: a copy is passed to the subroutine and discarded at the end, so its value outside of the subroutine won’t be affected.
What does passing by reference mean?
The address of the parameter is given to the subroutine, so the value will be updated at the given address.
What is an IDE?
A program which provides a set of tools to make it easier for programmers to write, develop and debug code.
5 features of an IDE
Stepping
Variable watch
Breakpoint
Source Code Editor
Debugging Tools
What is stepping (IDE)
Monitoring the effect of each individual line of code by executing a single line at a time
What is variable watch (IDE)
Used to pinpoint errors, lets you observe how the contents of a variable change in real time through the execution of a program.
What is a breakpoint(IDE)?
IDEs let users set a point in the program where it will stop, based on a condition or set at a specific line. Helps pinpoint errors.
What is a source code editor(IDE)?
Makes the coding process easier by providing features like word autocompletion, indentation, syntax highlighting and bracket completion.
What are debugging tools(IDE)?
Some provide run time detection of errors, with a guide as to where they have occurred through highlights and line numbers.
What is a class?
A template for an object defining it’s state and behaviour.
What is an object’s state?
Attributes defining it’s properties
What is an object’s behaviour?
Methods describing the actions it can perform.
What is an object?
A particular instance of a class
What is encapsulation?
In OOP, attributes are declared as private so can only be altered by public methods.
Why is encapsulation used?
To implement the principle of information hiding, protecting data from being accidentally edited by other parts of the program.
How does top down design implement encapsulation?
Each module is designed to be self contained.
What does performance modelling do?
Eliminates the need for performance testing by providing mathematical models to test a variety of loads on different operating systems.
Why is performance modelling useful?
It provides a cheaper, less time-consuming or safer method of testing applications, useful for safety critical computer systems where it isn’t safe to do a real trial run before the system is implemented.
What is visualisation?
Representing data in a way that is easier for us to understand.
Why is visualisation good?
It allows us to identify otherwise non-obvious trends, particularly among statistical data.
How are stacks implemented?
As an array which use a single pointer, to keep track of the top of the stack
How are queues implemented?
Also as arrays, but making use of two pointers, a front and a back. Front holds the position of the first element and back the next available space.
What is a linked list?
A list composed of nodes, each of which has a pointer going to the next item in the list and a value. Searching is performed by using a linear search through the pointers.
Depth first (post-order) traversal
Go deepest first, order you pass by on the right.
What are trees made of?
Nodes and edges, which can’t contain cycles and aren’t directed.
Breadth first
Visit all children from left to right, then go down a layer.
What is the difference between Dijkstra’s and A*
A* has two cost functions, the first being the actual cost (same as in Dijkstra’s), and second being an approximate cost from node x to the final node called a heuristic, which aims to make the shortest path finding process more efficient.
How to use string handling (pseudocode)
stringname.subString(startingPosition, numberofCaracters)
Reading from a file
myFile = openRead(“filename)
x = myFile.readLine()
or myFile.writeLine(“hello world”)
myFile.close()
myFile.endofFile determines end of file
Example of instantiation class pet
class Pet
private name
public procedure new(givenName)
name=givenName
endprocedure
Example of Dog inheriting from pet with added thing, breed.
class Dog inherits Pet
private breed
public procedure new(givenName, givenBreed)
super.new(givenName)
breed=givenBreed
endprocedure
endclass
Instance of a new class
name = new classname(parameters)