Algorithms and Programming Constructs Flashcards

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
Q

while repeat loop pseudocode

A

while
blah
repeat

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

Logical operators pseudocode

A

AND OR NOT XOR
TRUE FALSE

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

Subroutine definition

A

section of code in a program that carries out a specific task and can be done more than once

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

Sequence defintion

A

the instructions are written to be executed in a predetermined order (one action leads to the next)

29
Q

Selection definition

A

a question is asked and depending on the answer the program takes one of multiple courses of action

30
Q

iteration and
loop
defintions

A

an iteration is one pass through a process that is repeated
the set of instructions being repeated is the loop

31
Q

what does a for loop do

A

repeats a fixed number of times

32
Q

what does a while loop do

A

repeats until a condition at the beginning of the set of instructions is no longer reached

33
Q

what does a repeat loop do

A

repeats until a condition at the end of the set of instructions is reached

34
Q

what is a count variable

A

used to count how many times an iteration has occured

35
Q

what is a rogue value

A

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
Q

when can loops be ended

A

Loops can be ended when a rogue value is encountered or when a count variable reaches a certain number

37
Q

OOP defintion

A

Programming based on
collections of objects that interact
with each other.

38
Q

object definition OOP

A

An object is an instance of a class.
It has properties and contains the code and the data required

39
Q

class definiton OOP

A

A template or set of instructions for all objects within that class

40
Q

Method defintion OOP

A

an action or behaviour that an object is able to perform

41
Q

encapsulation definition OOP

A

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
Q

inheritance definition OOP

A

child classes inherit data and behaviours from the parent class

43
Q

abstraction definition OOP

A

only exposing high-level public methods for accessing an object

44
Q

Polymorphism defintion OOP

A

many methods can do the same task

45
Q

variable definition

A

a named storage used in the program that can change its value

46
Q

local variable definition

A

only accesible (declared and used) within limited parts of a program /subroutine/method/function

47
Q

global variable definition

A

Global variables are declared and used (accessible)
throughout the entire program.
(it can be called from subroutines or main program - anywhere!)

48
Q

identifier definition

A

a name given to a variable
should be sensible

49
Q

what is self-documenting code

A

code that explains itself

50
Q

string passing definition

A

a string is passed to a subroutine to be operated on

51
Q

concatenation definition

A

joining multiple strings together

52
Q

string comparison definition

A

Checking whether 2 strings reference the same object

53
Q

substitution definition in OOP

A

objects of a superclass can be replaceable with objects of a sub class

54
Q

trimming definition

A

removing leading and trailing spaces from a string

55
Q

what does DIV do

A

finds the quotient or ‘whole number of times’a divisor can be divided into a number e.g. 5DIV3 = 1

56
Q

MOD definition

A

finds the remainder when a divisor is divided into a number e.g. 5MOD3 = 2

57
Q

how does a merge sort work

A

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
Q

how does a bubble sort work

A

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
Q

how does a linear search work

A

the first item is compared with what youre looking for, then the second, then the third, etc

60
Q

how does a binary search work

A

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
Q

what is evaluation

A

making an informed judgement about
- the efficiency of the program
- whether it meets the original requirements
- whether it’s fit for purpose

62
Q

what is testing

A

checking the program produces the correct results under all circumstances

63
Q

three types of test data

A

normal data extreme data and abnormal data

64
Q

what is normal data

A

data that should be accepted

65
Q

what is exreme data

A

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
Q

what is abnormal data

A

data that should be rejected

67
Q

what is testing without a computer known as
uses what

A

dry running
trace table

68
Q

what does a trace table contain

A

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,