Algorithms and Programming Constructs Flashcards

(68 cards)

1
Q

What is an algorithm

A

A process/set of rules to be followed in order to produce a solution

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

Characteristics of an algorithm

A
  • Not language dependent (can be converted into any language)
  • unambiguous
  • will take an input, process it and produce an output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can algorithms be represented

A

using flowcharts, pseudocode or computer programs

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

start/stop procedure flowcharts

A

rectangle with curved corners

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

decision box flowcharts

A

diamond

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

input/output flowcharts

A

parallelogram

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

operation flowcharts

A

rectangle

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

connector flowcharts

A

circle

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

store/subroutine call flowcharts

A

rectangle with a line on each edge

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

flow of control flowcharts

A

arrow - arrowhead indicated direction of flow

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

declare & end subroutine pseudocode

A

Declare ThisIsASubroutine

End Subroutine

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

Call a subroutine pseudocode

A

call SubroutineNeeded

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

Declare and use arrays pseudocode

A

myarray[99]

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

Literal outputs pseudocode

A

output “Please enter a number”

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

Variable names pseudocode

A

myvariable

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

Define variable & data type pseudocode

A

myvariable is integer

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

Data types

A

integer, character, string, boolean, real

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

Assignment (of values to variables) pseudocode

A

set myvariable = 0

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

selection pseudocode

A

if ___ then
blah blah
end if

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

annotation pseudocode

A

{some annotation goes here}

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

For loop pseudocode

A

for i = … to …
blah blah
next i

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

repeat until loop pseudocode

A

repeat
blah blah
until …

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

do loop pseudocode

A

do
blah
loop

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

do while loop pseudocode

A

do
blah
while …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
while repeat loop pseudocode
while blah repeat
26
Logical operators pseudocode
AND OR NOT XOR TRUE FALSE
27
Subroutine definition
section of code in a program that carries out a specific task and can be done more than once
28
Sequence defintion
the instructions are written to be executed in a predetermined order (one action leads to the next)
29
Selection definition
a question is asked and depending on the answer the program takes one of multiple courses of action
30
iteration and loop defintions
an iteration is one pass through a process that is repeated the set of instructions being repeated is the loop
31
what does a for loop do
repeats a fixed number of times
32
what does a while loop do
repeats until a condition at the beginning of the set of instructions is no longer reached
33
what does a repeat loop do
repeats until a condition at the end of the set of instructions is reached
34
what is a count variable
used to count how many times an iteration has occured
35
what is a rogue value
a value that falls outside the normal data accepted by the program (e.g. a value of 7 in a while loop of while bob <= 6)
36
when can loops be ended
Loops can be ended when a rogue value is encountered or when a count variable reaches a certain number
37
OOP defintion
Programming based on collections of objects that interact with each other.
38
object definition OOP
An object is an instance of a class. It has properties and contains the code and the data required
39
class definiton OOP
A template or set of instructions for all objects within that class
40
Method defintion OOP
an action or behaviour that an object is able to perform
41
encapsulation definition OOP
wrapping data and the code that operates on it into a single entity; an object containing both the program code and its related data
42
inheritance definition OOP
child classes inherit data and behaviours from the parent class
43
abstraction definition OOP
only exposing high-level public methods for accessing an object
44
Polymorphism defintion OOP
many methods can do the same task
45
variable definition
a named storage used in the program that can change its value
46
local variable definition
only accesible (declared and used) within limited parts of a program /subroutine/method/function
47
global variable definition
Global variables are declared and used (accessible) throughout the entire program. (it can be called from subroutines or main program - anywhere!)
48
identifier definition
a name given to a variable should be sensible
49
what is self-documenting code
code that explains itself
50
string passing definition
a string is passed to a subroutine to be operated on
51
concatenation definition
joining multiple strings together
52
string comparison definition
Checking whether 2 strings reference the same object
53
substitution definition in OOP
objects of a superclass can be replaceable with objects of a sub class
54
trimming definition
removing leading and trailing **spaces** from a string
55
what does DIV do
finds the quotient or 'whole number of times'a divisor can be divided into a number e.g. 5DIV3 = 1
56
MOD definition
finds the remainder when a divisor is divided into a number e.g. 5MOD3 = 2
57
how does a merge sort work
it takes the unsorted list and splits it up into sublists each containing one element the sublists are repeatedly merged to produce new sorted sublists until there is only 1 list remaining
58
how does a bubble sort work
the algorithm compares each pair of adjacent items and swaps them if they are in the wrong order the passes through the list are repeated until no swaps are needed.
59
how does a linear search work
the first item is compared with what youre looking for, then the second, then the third, etc
60
how does a binary search work
the list is put in ascending order the middle value in the list is inspected to see if it matches the search value if the middle value is greater than the search value the upper half is discarded and the other way around the process is repeated with the list halving in size each time until the search is found
61
what is evaluation
making an informed judgement about - the efficiency of the program - whether it meets the original requirements - whether it's fit for purpose
62
what is testing
checking the program produces the correct results under all circumstances
63
three types of test data
normal data extreme data and abnormal data
64
what is normal data
data that should be accepted
65
what is exreme data
data that should be accepted and are on the extreme end of the range (e.g. 10 if inputs should be between 10 and 20 inclusive)
66
what is abnormal data
data that should be rejected
67
what is testing without a computer known as uses what
dry running trace table
68
what does a trace table contain
each column shows a variable and the output and each row shows the number input into the algorithm and the subsequent values of the variables and the output,