Problem solving and programming Flashcards

(36 cards)

1
Q

Alpha testing (at least 4 properties)

A

Testing within the development company //
testing by the developers
Testing it in the way the end user would
Used when the program is complete
Used when white box/black box/system etc.
testing is complete
Takes place before Beta testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Advantages of global variables (2 x AO1, 2 x AO2)

A

Simpler to program …
… because values do not need to be
passed/renamed/moved between different
subroutines
Do not need to worry about returning values //
do not need to decide between byval/byref …
… all parts of the program can access the
(same) value (in the same way)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Disadvantages of global variables (3 x AO1 and 3 x AO2)

A

Uses more memory …
… because the memory space is declared when the program starts and remains in use throughout (negligible for small programs)
Makes testing / debugging more difficult …
…. as it’s difficult to test an individual block of code
Reduces data accuracy / integrity …
…. changing a global variable may have an impact on another module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

IDE for debugging (AO1 and AO2, at least 3)

A

-Debugging tools (variable watchers) allow inspection of variable values, this can allow run-time detection of errors
-Code can be examined as it is running, which allows logical errors to be pinpointed
IDE debugging can produce a crash dump, which shows the state of variables at the point where an error occurs
-It can step through code, which allows the programmer to (watch the effects of each line of code and) check variables
-The insertion of a break-point, allows the program to be stopped at a predetermined point in order to inspect state of variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a function

A

-A function is a named section of program (1) that performs a specific task (1).
-It returns a value (1), it is often called inline (1).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is recursion

A

The function calls itself from within the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Recursion > iteration

A

-More natural to read (1)
-Quicker to write / less lines of code, (1) as some functions are naturally recursive (1)
-Suited to certain problems (1), for example those using trees (1)
-Can reduce the size of a problem with each call (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Recursion < iteration

A

-Can run out of stack space / memory (1) (due to too many calls (1)) causing it to crash (1) This can be avoided with tail recursion (1)
-More difficult to trace / follow (1) as each frame on the stack has its own set of variables (1)
-Requires more memory than the equivalent iterative algorithm.
-Usually slower than iterative methods (1) due to maintenance of the stack (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Difference between global and local variables

A

Global variable is visible throughout a program / may be accessed from more than one part of the program (all subroutines) (1), local variable is visible only in module construct where it is created / declared (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Properties of local variables (at least 3/4)

A

-Local variables are created in the subroutine they are
created in, they are not accessible directly from any
other subroutine
-Local variables are removed from memory when the
subroutine ends.
-Local variables can be passed as parameters to a
function to be updated, and then returned to override
the original local variable
-Local variables can be passed by reference to a
subroutine to allow the content of the variable to be
updated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Black box testing

A

Checks that given inputs give the correct output
No understanding of the code (not looking at the code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

White box testing

A

Understands the structure and logic of the program
Each line/path of code is tested

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Inspection (testing)

A

During a meeting a small team will read through code
Analysing it with a checklist which list the common problems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is IDE (integrated development environment)

A

A single program (1) used for developing programs (1) made from a number of components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When must a global variable be used

A

A global variable used where a value needs to be accessible from various parts of a program (1 – AO 1.2), it is the same value (1 – AO 1.2).
Irrespective of the place where it is accessed (1 – AO 1.2).
e.g. today’s date, VAT rate, pi (1 – AO 2.1).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Functions vs procedures

A

A function returns a single data type value (1), whereas a procedure can pass back many values (1) by parameter (1)
A function can be used in line (as part of a statement)
A function can be used as a variable
A procedure is used as any other program instruction

17
Q

What is a variable

A

A memory location
That stores data/a value
That can be changed

18
Q

OOP - what is a class

A

A class is a template (1) used to define methods and attributes (1) used to make objects

19
Q

OOP - what is inheritance

A

Inheritance is when a child class takes on all attributes (1) and methods (1) from a parent class (1). The inheriting class may override some of these methods / attributes (1) and may have additional extra methods and attributes of its own (1)

20
Q

OOP - what is encapsulation

A

Encapsulation is the process of keeping an object’s attributes private so they can only be accessed and changed via public methods

21
Q

OOP - what is an object

A

An object is an instance of a class

22
Q

OOP - what is an instance

A

An instance is a specific occurrence of a class

23
Q

OOP - how to make attributes private (python)

A

Double underscore after the dot
e.g. “self._ _name = name”

24
Q

OOP - what is polymorphism

A

Polymorphism means that objects of different types can be treated in the same way

25
Backtracking, definition and example (textbook)
-An approach to finding a solution that explores a possibility until it is no longer deemed feasible. At this point we "backtrack"/undo the last step to return to the last point at which it worked and follow a new path Examples: DFT, chess
26
Data mining, definition and purpose
-Analysis of patterns and anomalies in large data sets -Turns large quantities of data into useful information. These may not be immediately obvious to a **casual reader**. -Resulting information is used to make predictions, to increase revenue, to target advertising and improve services.
27
Data mining, disadvantages/limitations/things to consider (at least 3)
-Data mining can spot patterns/trends, however it cannot explain them. Company may still need to do extra research. -Requires powerful computers with a lot of processing power to process huge amounts of data. -Need to make sure data collection is legal and in terms and conditions -Analysis can be costly e.g. may need an external company -Security - data being collected requires protection
28
Conceptually, what is passing by value (textbook)
Passing by value sends a **copy** of the value to the subroutine
29
Conceptually, what is passing by reference (textbook)
Passing by reference send the **memory location** of the argument to the subroutine meaning the parameter points to that location
30
IDE features for writing a program
1 mark per identification 1 mark for expansion, max 2 each. Write: e.g. * Auto-complete * Start typing an identifier/command and it fills in the rest * Auto-indent * Indents code automatically within structures to avoid errors * Coloured command words // pretty printing // syntax highlighting * Shows which commands are correct // help identify key elements
31
Two features of any recursive program
* A function that calls itself // a function that is defined in terms of itself * …has a base case (that terminates the recursion)
32
OOP vs Procedural AO1
**AO1: Knowledge and Understanding Indicative content** * OOP defines an object as an independent entity * OOP defines the attributes of the object and the methods that can be applied to it * attributes could be private to restrict accidental changes * Procedural the statements are executed in the order they are written
33
Advantages of OOP over PP for several of the same structures (AO2)
*OOP allows for an object to be created from the structure * Many instances of this structure can then be declared in the main program. * Procedural will need each structure to be declared individually * Procedural will need to make use of subroutines where the structure will need to be sent and returned each time.
34
Advantages of OOP over PP for several of the same structures (AO3)
* OOP reduces amount of code needed therefore fewer errors are likely as code is written once and then used multiple times * OOP can reduce mistakes because the subroutines are self-contained. In procedural it would need to make sure the correct values are passed and returned, or global variables may be required which uses excess memory
35
Items of data to obtain before developing app
 Popularity data (1).  Platforms available (1).  Sales of existing similar apps (1).  Prices charged (1).  Does it exist already? (1).
36
Describe heuristic method (complete brainrot)
We don’t gather/measure all the data (1) about vehicle speeds (1). We scan for the data most likely to help us (1) and make a judgement based on experience (1).