Algorithms, design & provlem solving (paper 2) Flashcards

1
Q

what is the program development life cycle

A

analysis
design
coding
testing

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

define decomposition

A

breaking down a complex problem into smaller, manageable parts which are easier to solve

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

what are the steps of decomposition

A
  • identify main problem
  • identify the componenet parts of inputs, processes, outputs and storage
  • list the main sub-problems, sub-systems or sub-tasks
  • break these down into smaller sub-problems and sub-tasks which can be completed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is a structure diagram used for

A

to show the structure of a problem, its subsections and links to other subsections

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

what is abstraction

A

simplifing a porblem so it is easier to be deal with

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

what are flowcharts used for

A

to develop solutions to a problem

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

what is the problem with using flowcharts

A

they di not usually translate very easily into program code

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

why do programmers use pseudocode

A

because it is easier for someone to understand - they can focus on the process needed rather than the coding itself

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

what is the assingment operator for pseudocode

A

an arrow
<-

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

what is this <

A

less than

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

what is this >

A

greater than

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

what is this <>

A

not equal to

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

what are the data types

A
  • integer
  • real
  • boolean
  • char
  • string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is an integer

A

a whole number

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

what is a real

A

a number with a decimal point

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

what is a boolean

A

true or false

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

what is a char

A

a single alphabetic or numeric character

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

what is a string

A

a sequence of one or more characters

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

what is the difference between a variable and constant

A

a variable can be changed/updated/edited after exercution but a constant stores a value that cannot be changed after exercution

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

what are the 3 types of code

A
  • sequence (inputs, outputs, assignment)
  • iteration (loops)
  • selection (conditions)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

what is stepwise refinement

A

when the code happens in order of it being written

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

in pseudocode if statements what do you particually need

A

IF …
THEN
ELSE IF
THEN
ELSE
END IF

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

what are the three iteration statements

A
  • for … next
  • while … endwhile
  • repeat … until
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

when are case statements used

A

if there are several possible options ot be tested

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

how are case statements written

A

CASE OF ….
1 : …
2 : …
OTHERWISE
ENDCASE

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

what is MOD

A

the remainder of

27
Q

what is DIV

A

quotient (normal division)

28
Q

what is sequence

A

two or more statements written and executed one after the other

29
Q

what are the string operations

A

LENGTH()
LCASE()
UCASE()
SUBSTRING()

30
Q

how do you write a min algorithm from an array list

A

ages <- [99, 15, 25, 55, 61]
min <~ 100
FOR index <- 1 TO 5
IF ages[index] < min
THEN
min <- age[index]
ENDIF
NEXT index
OUTPUT “The lowest age is “, min

31
Q

how do you write a max algorithm from an array list

A

ages -> [99, 15, 25, 55, 61]
max -> 0
FOR index -> 1 TO 5
IF ages[index] > max
THEN
max -> age[index]
ENDIF
NEXT index
OUTPUT “The highest age is “, max

32
Q

what is the RLE algorithm

A

RLE uses frequency/data pairs to encode each run length of the same coloured pixle

33
Q

what is involved in the analysis stage of the program development life cycle

A
  • abstraction
  • decomposition of the problem
  • identification of the problem and requirments
34
Q

what is involved in the design stage of the program development life cycle

A
  • decomposition
  • structure diagrams
  • flowcharts
  • psuedocode
35
Q

what is involved in the coding stage of the program development life cycle

A
  • writing program code
  • iterative testing
36
Q

what is involved in the testing stage of the program development life cycle

A
  • testing program code with the use of test data (abnormal, normal, boundary, extreme)
37
Q

what is this flow chart symbol for, give and example

A

a decision - IS number <= EndNumber

38
Q

what is this flow chart symbol for, give and example

A

input or output - INPUT EndNumber

39
Q

what is this flow chart symbol for, give and example

A

a process - Number <- StartNumber

40
Q

what is this flow chart symbol for, give and example

A

start or terminator - START, STOP, END

41
Q

what is this flow chart symbol for, give and example

A

a subroutine - name of a different routine / flow chart

42
Q

what happens in a linear search

A

each item to be searched from will be checked one by one in the list until the item is found or an error is outputted

43
Q

what are the two types of search routines

A
  • linear
  • bubble
44
Q

what is the code for a linear search routine

A

// perform a linear search of an array
DECLARE AList : ARRAY[1:10] OF INTEGER
AList <- [14, 2, 3 ,11, 1, 9, 5, 8, 10, 6]
OUTPUT “List to be searched:”, AList
Found <- FALSE
Index <- 1
INPUT SearchItem
WHILE Found = FALSE AND Index <= LENGTH(AList) DO
IF AList[Index] = SearchItem
THEN
Found <- TRUE
ELSE
Index <- Index + 1
ENDIF
ENDWHILE
IF Found = TRUE
THEN
OUTPUT SearchItem, “in position”, Index, “of the list”
ELSE
OUTPUT “Item not found”
ENDIF

45
Q

what happens in a bubble sort

A

it repeatedly goes through the list to be sorted, swapping adjacent elements if they are in the wrong order

46
Q

what is the code for a bubble search

A

//bubble sort with flag set when no swaps are made
AList <-[17, 3, 7, 15, 12, 23, 20]
// get number of items in the array
NumItems <- LENGTH(AList)
Comparisions <- NumItems - 1
SwapMade <- TRUE
WHILE Comparisons > 0 AND SwapMade = TRUE
SwapMade <- FALSE
FOR i <- 1 TO Comparisons
IF AList[i] > AList[i + 1]
THEN
Temp <- AList[i]
AList[i] <- AList[i + 1]
AList[i + 1] <- Temp
SwapMade <- TRUE
ENDIF
NEXT i
Comparisons <- Comparisons - 1
ENDWHILE
OUTPUT “Sorted list: “, AList

47
Q

what are data validation checks used for

A

to check the validility of data entered by the user

48
Q

what are the different types of validation checks

A
  • range check
  • length check
  • type check
  • presence check
  • format check
  • check digit check
49
Q

what is the purpose of a range check

A

data must lie within a given range

50
Q

what is the purpose of a length check

A

a strung input must be greater than or equal to a minimum length

51
Q

what is the purpose of a type check

A

data must be of the correct data type (interger, boolean)

52
Q

what is the purpose of a format check

A

eg a postcode must conform to one of a number of set formats

53
Q

what is a check digit check

A

an addition digit at the end of a porduct code designed to check that valid product code has been entered

54
Q

what is a doubt-entry verification check

A

when the two data entries are entered they are compared and if they match then the entery is accepted

55
Q

what are normal test data

A

using examples of typical data that the program is designed to handle

56
Q

what are extreme test data

A

the largest and smallest acceptable values

57
Q

what are boundary test data

A

inclueds both ends of the allowed data range

58
Q

what is abnormal test data

A

data of the wrong type

59
Q

what is a trace table used for

A

to document how the values of variables change during a dry-run of an algorithm

60
Q

what are the three different types of error

A
  • syntax error
  • logic error
  • runtime error
61
Q

what is a syntax error

A

something that prevents your program from running caused by a mistake in the spelling or ‘grammer’ of the code

62
Q

what is a logic error

A

when an unexpected output is given like the wrong symbol for greater than / less than

63
Q

what is a runtime error

A

an error which is detected while the program is running, like data is not entered in time or wrong data entered