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
how are case statements written
CASE OF .... 1 : ... 2 : ... OTHERWISE ENDCASE
26
what is MOD
the remainder of
27
what is DIV
quotient (normal division)
28
what is sequence
two or more statements written and executed one after the other
29
what are the string operations
LENGTH() LCASE() UCASE() SUBSTRING()
30
how do you write a min algorithm from an array list
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
how do you write a max algorithm from an array list
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
what is the RLE algorithm
RLE uses frequency/data pairs to encode each run length of the same coloured pixle
33
what is involved in the analysis stage of the program development life cycle
- abstraction - decomposition of the problem - identification of the problem and requirments
34
what is involved in the design stage of the program development life cycle
- decomposition - structure diagrams - flowcharts - psuedocode
35
what is involved in the coding stage of the program development life cycle
- writing program code - iterative testing
36
what is involved in the testing stage of the program development life cycle
- testing program code with the use of test data (abnormal, normal, boundary, extreme)
37
what is this flow chart symbol for, give and example
a decision - IS number <= EndNumber
38
what is this flow chart symbol for, give and example
input or output - INPUT EndNumber
39
what is this flow chart symbol for, give and example
a process - Number <- StartNumber
40
what is this flow chart symbol for, give and example
start or terminator - START, STOP, END
41
what is this flow chart symbol for, give and example
a subroutine - name of a different routine / flow chart
42
what happens in a linear search
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
what are the two types of search routines
- linear - bubble
44
what is the code for a linear search routine
// 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
what happens in a bubble sort
it repeatedly goes through the list to be sorted, swapping adjacent elements if they are in the wrong order
46
what is the code for a bubble search
//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
what are data validation checks used for
to check the validility of data entered by the user
48
what are the different types of validation checks
- range check - length check - type check - presence check - format check - check digit check
49
what is the purpose of a range check
data must lie within a given range
50
what is the purpose of a length check
a strung input must be greater than or equal to a minimum length
51
what is the purpose of a type check
data must be of the correct data type (interger, boolean)
52
what is the purpose of a format check
eg a postcode must conform to one of a number of set formats
53
what is a check digit check
an addition digit at the end of a porduct code designed to check that valid product code has been entered
54
what is a doubt-entry verification check
when the two data entries are entered they are compared and if they match then the entery is accepted
55
what are normal test data
using examples of typical data that the program is designed to handle
56
what are extreme test data
the largest and smallest acceptable values
57
what are boundary test data
inclueds both ends of the allowed data range eg for 1-100, 101 or 0
58
what is abnormal test data
data of the wrong type
59
what is a trace table used for
to document how the values of variables change during a dry-run of an algorithm
60
what are the three different types of error
- syntax error - logic error - runtime error
61
what is a syntax error
something that prevents your program from running caused by a mistake in the spelling or 'grammer' of the code
62
what is a logic error
when an unexpected output is given like the wrong symbol for greater than / less than - the program works but not as the programmer expected it to
63
what is a runtime error
an error which is detected while the program is running, like data is not entered in time or wrong data entered