Anda di halaman 1dari 5

Software Development Techniques

12 May 2014

Examination Paper
Answer ALL questions.

Clearly cross out surplus answers.

Time: 3 hours
Any reference material brought into the examination room must be
handed to the invigilator before the start of the examination.
Answer ALL questions

Marks
Question 1

a) Briefly describe the following types of computer programming languages.


i) Machine code 2
ii) High-level languages 2

b) Explain the process of approximation in a desk-check and discuss its appropriateness 6


with regards to the two kinds of loops in programming.
Total 10 Marks

Question 2

The function below calculates the value of n to the power of p (for example, if n = 3 and 10
p = 4 then the function will calculate 34). Perform a desk check on this function using a
table like the template shown below. The input values for the desk check are n = 2 and
p = 3. The first five lines have been completed for you.

1. function calcPower (needs n as whole number, p as whole number) returns whole


number
2. data counter as whole number
3. data answer as whole number
4. counter = 1
5. answer = n

6. loop while counter < p


7. answer = answer * n
8. counter = counter + 1
9. next loop
10. return answer
11. end function

Line n p counter answer Notes


Number
1 2 3 N/A N/A
2 2 3 N/A N/A
3 2 3 N/A N/A
4 2 3 1 N/A Value of counter set to 1
5 2 3 1 2 Value of answer set to n (which is
2)

Total 10 Marks

Questions continue on next page


Page 2 of 5
Software Development Techniques June 2014 Final © NCC Education Ltd 2014
Marks
Question 3

a) Computer programs can use different data types. For each of the following, suggest
an appropriate data type and justify your decision.
i) National Insurance number in the format: 2 letters, 6 numbers, 1 letter 2
ii) Daily rainfall in metres 2
iii) The number of millilitres of liquid a particular container can hold 2

b) Identify FOUR (4) benefits that come from using functions in code. 4

Total 10 Marks

Question 4

a) Provide the truth table for the logical comparison (A AND B) AND (B OR C) OR (NOT 6
A).

A B C (A AND B) (B OR C) (A AND B) AND NOT A Result


(B OR C)

T T T F T
T T F F T
T F T F F
T F F F F
F T T T T
F T F T T
F F T T T
F F F T T
b) Explain what is meant by the term compound conditional. 2

c) Explain what is meant by the term lazy evaluation. 2

Total 10 Marks

Questions continue on next page


Page 3 of 5
Software Development Techniques June 2014 Final © NCC Education Ltd 2014
Marks
Question 5

a) Explain what the following function does. 6

function myFunction(needs n as whole number) returns string


if n >= 0 and n < 50
return “Fail”
else if n >= 50 and n < = 100
return “Pass”
else
return “Invalid exam mark.”
end if
end function

b) Rewrite the function from part (a) so that the user can set the lower, pass/fail 4
boundary, and upper values to be used in the selection statements.

Total 10 Marks

Question 6

a) Describe the process of integration testing and explain its relationship to unit testing. 4

b) When conducting unit testing, it is important to include test cases for valid, boundary 6
and invalid data. Explain what valid, boundary and invalid mean in the context of
software testing and provide an example of each for the function below.

function checkValid(needs n as whole number) returns boolean


if n >= -2000 and n <= 85000
return true
else
return false
end if
end function

Total 10 Marks

Questions continue on next page


Page 4 of 5
Software Development Techniques June 2014 Final © NCC Education Ltd 2014
Marks
Question 7

a) A linear search is the simplest form of search function. It sequentially compares each 6
element in an array against the item being searched for.

Provide the pseudocode for a linear search function on an array of whole numbers.
The function should take in the array and the search term as parameters. It should
return the index at which the number was found, or return -1 if the number was not
found in the array.

b) Explain, with reference to Big O Notation, why linear search does not scale as well as 4
binary search.

Total 10 Marks

Question 8

a) Draw a diagram of an array called janWeekOneRainfall which has been initialised to 5


hold 7 real numbers (the amount of rainfall in centimetres for each of the first 7 days
in January). Your diagram should indicate the structure of the array, with the different
parts clearly labelled.

b) Write the pseudocode to declare the janWeekOneRainfall array and fill the array with 5
values entered by the user.

Total 10 Marks

Question 9

Provide a pseudocode representation of a Stack for whole numbers, including the push 10
and pop functions required to add and remove from it.

Total 10 Marks

Question 10

a) Give a pseudocode outline of a class called Student. Its attributes are StudentID, 6
Name, Course of Study and Age. The StudentID is a code comprised of 2 letters
followed by 5 numbers. The student age is stored as a whole number rather than date
of birth.

b) Using the class from part (a), add a constructor method that allows for all four of these 4
values to be set when the object is instantiated.

Total 10 Marks

End of examination
Page 5 of 5
Software Development Techniques June 2014 Final © NCC Education Ltd 2014

Anda mungkin juga menyukai