2.2 Problem solving and programming Flashcards
What is branching
A programming control structure where the code selects one or more alternative paths depending on the evaluation of a Boolean expression
What are functions
A subroutine that can be called to perform a task or calculation and will always return a value
What are global variables
A variable declared in the main program which exists outside any of the subroutines but can be used anywhere in the program
Integrated development environment
A software package the allows a user to develop and implement code more easily with features for editing, debugging, version control, testing and compilation
Iterations
A programming control structure where as set of statements is repeated either a fixed number of times or until a condition is met
Local variables
A variable declared within a subroutine of a program which only exists and can be used within that subroutine
Modularity
Breaking down a complex problem into simpler, self-contained components called modules
What is each module
An implementation of a specific subtask required to solve a problem
What is object oriented programming
Pp Where the system is viewed as a set of objects with their own attributes and procedures that can interact with each other
What is all processing done by in OOP
Objects
Passing by reference
Passing the address or pointer of the required value into a procedureP
Passing by value
Creating a temporary local copy of the actual value of a variable and passing it into the procedure
Parameters
The data structures required to be passed into a subroutine
Procedures
A subroutine that is called by simply writing its name in the code. Procedures do not have to return a value in the program
What is recursion
A programming subroutine where a section of code calls itself until a base case is met. The base case must be chosen to avoid any possibility of an infinite loop
What are sequences
A programming control structure in which statements are executed one after another as they appear in the script
Subroutines
A uniquely named section of code that is written to perform a specific task within a program
What is backtracking
An algorithms that incrementally finds a solution by methodically trying different sequences and abandoning a path when it knows it cannot lead to a valid solution
Computable problems
A problem for which every instance can be solved in a finite number of steps by means of an algorithm
Computational methods
A method of solving a problem which by some form of computation in devising and implementing an algorithm
Data mining
An algorithms that finds a solution by analysing a large data set to uncover trends and relationships between variables
What is divide and conquer
An algorithm design technique to decompose and solve problems by reducing the problem size with each iteration until the sub problem becomes solvable
Heuristics
A rule of thumb algorithm which can produce a valid albeit sub-optimal solution for a hard (intractable) problem as an approximation
Performance modelling
The process of simulating the behaviour of a model under different virtual user and system loads by mathematical approximation
What is pipelining
The process of splitting a task into parts and then searching for subtasks that can be processed simultaneously to overlap the processing of each part
What is problem decomposition
The process of splitting a given problem into smaller, solvable sub-problems that are easier to conceive, understand, maintain and program
What is problem recognition
The ability to recognise the most effective strategy to solve a problem
What is visualisation
The use of a visual representation of an algorithms or data structure to translate a problem and it’s solution to a more human readable form
What is sequence
Code is executed line-by-line, from top to bottom
What is branching
A certain block of code is run if a specific condition is met, using IF
statements. This is also known as ‘selection’
What is iteration
A block of code is executed a certain number of times or while a condition is
met. Iteration uses FOR, WHILE or REPEAT UNTIL loops.
Iteration can be eitherT
Two types of iteration
Count controlled and condition controlled
What is recursion
subroutine
calls itself during its execution. This continues until a certain
condition - called the stopping condition - is me
Advantage of recursion
Sometimes fewer lines of code are needed
What is the stopping conditions called in recursion
Base case
What should the stopping condition be reachable within
A finite number of times
What does a modular design also make it easier to do
Divide tasks between a team and manage whilst simplifying the process of testing and maintenance as each component can be dealt with individually
What does modular programming improve
The reusability of components
Example of stepwise refinement (top down approach)
Should you assume by ref or by val?
Assume they are passed by value
What does and IDE do in simple terms
Make it easier for programmers to write, develop and debug code
What are some examples of IDE’s
PyCharm, Eclipse, IDLE and Microsoft Visual Studio
What is stepping (IDE)
This allows you to monitor the effect of each individual line of code by
executing a single line at a time
What is variable watch (IDE)
Sometimes used to pinpoint errors, this is a useful feature to observe how
the contents of a variable change in real-time through the execution of a
program.
What is breakpoint (IDE)
Sometimes used to pinpoint errors, this is a useful feature to observe how
the contents of a variable change in real-time through the execution of a
program.
What is source code editor (IDE)
The editor aims to make the coding process easier by providing features
such as autocompletion of words, indentation, syntax highlighting and
automatic bracket completion.
What are debugging tools (IDE)
Some IDEs also provide run-time detection of errors with a guide as to where
in the code they are likely to have occurred through line numbers and
highlighting
What is a class
A template for an object and defines the state and behaviour of an object.
What is state
Given by the attributes which give an objects properties
What is behaviour
Defined by the methods associated with a class which describe the actions it can perform
What is the process that creates objects using classes
Instantiation
What is an object in relation to a class
A particular instance of a class
Are attributes public or private
Private so can only be altered by public methods
What is it called when attributes are made private
Encapsulation
What does encapsulation Implement
The principle of information hiding and makes programs simpler by protecting data being accidentally edited
How does top down design implement encapsulation
Makes each module designed to be self contained
What makes a program computable (solvable using an algorithm)
Problems can only be called
computable if they can be solved within a finite, realistic amount of time
Problem recognition
Stakeholders state what they require from the finished
product and this information is used to clearly define the problem and the system
What are the requirements defined by
Analysing strengths and weaknesses with the current way this problem is being
solved
● Considering types of data involved including inputs, outputs, stored data and
amount of data
What else does problem decomposition allow
The project to be developed in parralel
What is divide and conquer
r is a problem-solving technique used widely across computer science.
This strategy can be broken down into three parts: divide, conquer and merge
Example of divide and conquer
Binary search
Biggest advantage of divide and conquer
size of the problem is halved with each
iteration which greatly simplifies very complex problems.
This means that as the size of a problem grows, the time
taken to solve it will not grow as significantly
What is a stack ovrerflow
when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
Representational abstraction
Excessive details removed
Abstraction by generalisation
Grouping together section of problem with similar functionality allow code to be re used
Backtracking
y methodically visiting each path and building a solution based on
the paths found to be correct. If a path is found to be
invalid at any point, the algorithm backtracks to the
previous stage and visits an alternate path
Example of backtracking
Depth-first graph traversals
What is data mining
Data mining is used in
software designed to spot trends or identify correlations between data which are not
immediately obvious (looking for patterns)
What can insights from data mining be used to make
Data mining is used in
software designed to spot trends or identify correlations between data which are not
immediately obvious
Crucial thing with data mining
, as data mining often involves the handling of
personal data, it is crucial that it is dealt with in
accordance with the present legislation regarding data
protection
Heuristics
Non optimal approach to problem solving to find an approximate solution when standard solution is time consuming or resource intensive
Example of heuristics
A* algorithm
Performance modelling
Performance modelling eliminates the need for true performance testing by providing
mathematical methods to test a variety of loads on different operating systems.
Advantages of performance modelling
cheaper, less time-consuming or safer method of
testing applications
Use of performance modelling
This is useful for safety-critical computer systems, such as those used
on an airplane, where it is not safe to do a real trial run before the system can be
implemented
Pieplining
faster, as modules are divided into individual
tasks, with different tasks being developed in parallel
What is a production line
Traditionally, the output of one process in pipelining
becomes the input of another, resembling a production
line.
Visualisation
Data can be presented in a way that is easier for us to understand using visualisation. This
makes it possible to identify trends that were not otherwise obvious, particularly amongst
statistical data
What is polymorphism
Polymorphism is a concept in programming that allows objects to take on different forms or behaviours.