Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web

August 1999
CP103 : COMPUTER PROGRAMMING

SECTION B [60 Marks]

Click here to access other sections
Section A
Front Cover

SUGGESTED SOLUTIONS
Solutions and allocated marks are indicated in green.
Return to Section B (Questions)

 

Answer ANY TWO questions in this section

 

1. (a) A linear search for a particular record in an array of records works as follows. Suppose that there are N student records (stud_rec) in a student file. A counter, 'i', is set to 1 to start searching from the first record. A flag, 'found', is set to false before searching starts. Once the target record is found, 'found' will be set to true so that the searching loop will be terminated.

There are two conditions for the loop : the first involves the value of 'found' and the other involves the value of 'i'. If both conditions are true, stud_rec[i] is compared with the target record. If there are equal, a message should be displayed giving the position of the target in the array. The value of 'found' is then set to true. If target is found, the value 'i' is incremented by 1 to go to the next record. The entire process is repeated until the value of 'found' is set to true or the value of 'i' no longer lies between 1 and N.

After the loop, the value of 'found' is checked: if it is false, a message is displayed saying that the target has not been found in the student file.

Construct a flowchart which describes the above linear search algorithm.

  pic2.gif (23127 bytes)

Having correct symbol for both 'start' AND 'stop'
Rectangle to initialise a counter (i) to 1 AND set a flag (found) to an initial value
Diamond for checking value of 'found' inside loop
Diamond for checking value of 'i'
Diamond for checking stud_rec[i]=target
Rectangle to negate value of 'found' once target found
Correct display symbol to indicate record found at i (inside loop)
         OR indicate record not found (outside loop)
Rectangle to increment value of i by 1
Diamond for checking value of 'found' outside loop
Arrows on all (or almost all) of the flow lines
Correct points to loop back (with correct direction of arrow heads),
          one at exit point of 'i=i +1' AND one at 'found=true'
Correct entry point to the loop after the two initialisations
Correct labelling of 'Y' and 'N' on the 4 diamonds exit points

 

 

 

 

 

 

 

 

 

 

[16]

(b) Identify the three types of programmers in the programming group. For each, state two of the job responsibilities for members of that group.

Analyst Programmers
Any two of the following:
- assist the system analyst
- analysis and design of programs
- interview the users
- perform duties of system analyst

System Programmers
Any two of the following:
- design and develop system software
- evaluate, test, install and maintain software
- provide software tools and services to the application
  development process and end users
- problem solving in system errors and malfunction

Application Programmers
Any two of the following:
- translate program specifications and design into error free
  programs
- test and debug logic errors
- produce program documentation
- participate in walkthroughs
- maintain application systems

 

[9]
(c)

(i) Explain briefly what a recursive procedure is.
A recursive procedure is one that calls itself.
Each time it calls itself, it operates on different parameters.
It contains terminating condition/stopping case to end the recursive calls

(ii) Give one advantage and one disadvantage of using recursion as compared to iteration.
Advantage : it may be possible, using recursive, to specify a natural, simpler solution to solve an iterative problem

Disadvantage: less efficient, in terms of computer time, than iteration because of the overhead for the extra procedure calls

 

 

[3]

[2]

2. (a) Give two advantages of each of the following program design checking methods:

 

(i) Dry run
Causes the designer to take a second hard ;look at the detail of the design
ensuring that the initial design is proven before code is written

 

[2]
(ii) Structured walkthrough
[Any two of the following]
Early exposure of problems
Interaction between team members
Education of team members
Constant awareness of progress
Consistency of design approach within the group

 

[2]
(iii) Independent inspection
Allow a person other than the author to see the potential problems and evaluate them objectively
so a different view or unidentified problem may be spotted

 

[2]
(b)

(i)Explain what is involved in Program Maintenance.
The correction of any faults that occur in program execution when in use
The improvement of a program by adding enhancements to the program when necessary.

(ii) Give three actions programmers can take on to make program maintenance easier.
Any three of the examples given below of good practice :
The programmer should be use :
standard structure
meaningful identifiers
comments
good layout / indentation

 

 

[4]

[3]

(c) An employee record is made up of the following fields :
Employee number
Employee date of birth
Employee address
Employee basic salary
Category of job (managerial or non-managerial)
Employee part job(s) history (designation and last drawn salary)

 

(i) Create a data structure diagram for the above record.

pic3.gif (13630 bytes)

Start with Employee record(level 1)
All fields present in level 2
Tree structure
For showing managerial/non-managerial are children of category of job
For showing designation/last drawn salary are children of past job history
Use of * for iteration
Use of o for selection
For having a completely correct solution
For using meaningful datanames in each rectangle

 

[9]
(ii) Explain two differences between data types and data structure, and give two examples of each.

Data type is a description of data items of the same form
Data structure is the organised collection of items which can be of the same or different data types
Examples of data type :
character/string/integer/real/boolean(logical)/pointer/date

(Do not accept numeric / non-numeric)
Examples of data structure :
record/array/linked list/stack/queue/tree

 

[8]
3. (a) Explain what is meant by a test harness and a dummy stub. You may use the diagram below to help your explanation.

pic1.gif (3428 bytes)

Test harness :
It is a 'driver' used to execute low-level module
It is used in bottom up testing
It provide an overall structure of program in skeleton form, so that each component can be tested independently
In the diagram, A is a test harness that provide interface between B, C and D so that B can be tested independently

Dummy stub :
It acts as stand in component when the full routine o of the component is not yet written
It is used in top down testing
It usually consists of a simple display statement to announce its execution and control is then passed back to the calling module
In the diagram, B, C and D can acts as dummy stub to see whether they can be executed by A ( or interface with A)

 

[8]
(b)

(i) State the purpose of SQA.

It is a planned and systematic series of actions that are performed to ensure quality in software

(ii) List the major activities which are involved in SQA.

Application of technical methods
Conduct formal technical reviews
Testing of software
Enforcement of standards
Control of change
Measurement
Record keeping and reporting

 

 

[2]

[7]

(c)

(i) Explain briefly the differences between limited entry and mixed entry decision tables.

Limited entries decision table :
Condition entries are limited to 'Y' or 'N'
Action entries are limited to either 'X' or '-'

(ii) Write brief notes to explain what is meant by a decision table preprocessor.

Mixed entried decision table :
Condition entries not limited to 'Y' or 'N' but extended to entries using relational operator (>, >=, <, <=, <>)
Action entries not limited to 'X' or '-' but extended to value entry

 

 

[4]

 

[4]

(d) Use pseudocode to construct a for-loop which prints out all odd numbers between 1 and 10.

FOR i IN RANGE 1 TO 10
DO
        IF (i MOD 2 <> 0)
                  PRINT i
ENDDO

 

[5]1