(a) |
Write pseudocode for the initialisation section marked Initialisation_goes_here, if the maximum length of the text to be searched is 100 characters.
|
2 |
Suggested answer |
INITIALISATION
Text as Array of length 100
Pattern as Array of length 100
set TextPos to 1
set PatternPos to 1
ENDINITIALISATION
|
Criteria | Marks |
|
2 |
- Pseudocode has minor errors
|
1 |
|
|
(b) |
If there is a failure to match, the code following the ELSE statement is reached, marked here as reset_values.
|
|
| (i) |
Identify the values which must be reset and justify the order in which they must be reset.
|
2 |
Suggested answer |
- TextPos and PatternPos
- TextPos before PatternPos
|
Criteria | Marks |
- Identifies values and justifies their order
|
2 |
|
1 |
|
|
| (ii) |
Write pseudocode for the section marked reset_values and explain the logic of your answer.
|
4 |
Suggested answer |
- patternPos=1
- TextPos=(TextPos-PatternPos) + 2
- Since we have to go back to the Pos where the search started matching then add 1. The start will be PatterPos-1 elements back
|
Criteria | Marks |
- Correct pseudocode and explanation
|
4 |
- One mark off for each error
|
1-3 |
|
|
| (iii) |
The algorithm does not indicate whether or not a match has occurred after the repeat loop has exited. Write pseudocode for the section marked report_any_matches and explain the logic of your answer
|
2 |
Suggested answer |
- If the value of PatternPos>length of search then match has occurred
- (place this after the loop)
- logic: this only occures when the search pattern has matched
|
Criteria | Marks |
- Correct pseudocode and explanation
|
2 |
- One mark off for logic failure or pseudocode error
|
1 |
|
|
(c) |
The programmer has been asked to add a feature to this algorithm to allow a '?' symbol to match any character. Write pseudocode to perform this function.
|
2 |
Suggested answer |
Increment PatternPos and TextPos by 1 if the current element in Pattern equals '?'
|
|
|
(d) | (i) |
Outline the steps a software programmer should take prior to coding this module for use in a software application.
|
2 |
Suggested answer |
- Desk checking thoroughly
- Volume real data testing
- User testing
- Test on many systems
|
Criteria | Marks |
- Thoroughly outlines steps a programmer should take prior to coding the module
|
2 |
- Less than THREE steps outlined
|
1 |
|
|
| (ii) |
Identify ONE other feature which could be added to dhis algorithm
|
2 |
Suggested answer |
wildcards
|
Criteria | Marks |
- Identifies one other feature
|
2 |
|
1 |
|
|
(e) |
In coding the algorithm, the programmer should produce documentation. Describe THREE of these types of documentation and justify their inclusion.
|
4 |
Suggested answer |
- Internal
- Intrinsic
- Manual
- Installation
- Gantt chart
- Structure chart
|
Criteria | Marks |
- Describes THREE types of documentation a programmer should produce
|
4 |
- No justification OR no description OR fewer than THREE items provided
|
1-3 |
|
|