SDT Winter Exam 2022 QP FINAL (3)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Software Development Techniques

23rd November 2022

Time-Controlled Assessment Paper


Answer ALL questions.

Clearly cross out surplus answers.

Time: 4 hours

The maximum mark for this paper is 100.

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

The class Hotel is defined as

Class Hotel
Data Rooms as whole number
Data Address as string
Data Distance as real number

Function Hotel (needs R as whole number, A as string, D as real number)


Rooms = R
Address = A
Distance = D
End function

Function Hotel()

End function

Function GetRooms() ………………….


………………….
End function

Function SetDistance(………………….)
………………….
End function

End class

a) The function Hotel has the same name as the class name. What is such a function 2
generally known as and what is the main purpose of this function?

b) There are TWO (2) functions by the same name Hotel. 2

What are the functions with same name known as in object-oriented languages?

What feature of the TWO (2) functions uniquely distinguishes them?

c) The functions GetRoom and SetDistance have missing parts. 4

Fill in the missing parts.

Questions continue next page

Page 2 of 8
Software Development Techniques © NCC Education Limited 2022
d) What are the functions GetRoom and SetDistance generally known as in object- 2
oriented languages?

What purpose do they serve?

Total 10 Marks

Question 2

a) The following numbers are put in a queue: 1, -2, 5, -10, in that order.

i) What number is at the tail of the queue? 1

ii) What number is at the head of the queue? 1

iii) TWO (2) numbers are taken from the head of the queue. 2

The TWO (2) numbers are then multiplied, and the result is put in the queue.

List the contents of the queue, starting from the head of the queue.

b) The following numbers are put on a stack: 1, -2, 5, -10, in that order.

i) What number is at the bottom of the stack? 1

ii) What number is at the top of the stack? 1

iii) TWO (2) numbers are taken from the top of the stack. 2

The TWO (2) numbers are then multiplied, and the result is put on the stack.

List the contents of the stack, starting from the top of the stack.

c) What TWO (2) complex data types are normally used to be queue and stack data 2
structures?

Total 10 Marks

Questions continue next page

Page 3 of 8
Software Development Techniques © NCC Education Limited 2022
Question 3

a) Below is a segment of a program composed of multiple selections. The parts of the 7


program for the selections are left out as they are not important here.

If value < 1 and value > -5 then


output(“Low range value”)
otherwise if value >= 1 and value < 5 then
output(“High range value”)
otherwise output (“Error”)

Fill in the test values in the table below for each type of test condition. You must
use only whole numbers as test values.

Test condition Test values


Transition in values (maximum 3)
Extreme values (maximum 2)
Bad values (maximum 2)

b) In the table below is a list of THREE (3) test methods used in testing the 3
correctness of programs. Fill in the missing parts of the test method descriptions.

Test method Test method description


Regression testing Used to test the program after ……… are made
to it
Integration testing Used to test the ……… between the main
program and its functions
Unit testing Used to test functions in …………

Total 10 Marks

Question 4

a) Describe the requirements stage of Software Development Life Cycle (SDLC). 3

Which stage comes after the requirements stage?

b) Identify TWO (2) software development models in use today. 2

c) Explain FIVE (5) goals of software development models. 5

Do not explain the individual models.

Total 10 Marks

Questions continue next page

Page 4 of 8
Software Development Techniques © NCC Education Limited 2022
Question 5

The following program gets the number of books from the user.

If the number is not ZERO (0), it adds this number to the total.

This is repeated until the user enters ZERO (0).

Data books as whole number


Data total as whole number

read books
if books greater than 0 then
total = total + books
read books
if books greater than 0 then
total = total + books
read books
if books greater than 0 then
total = total + books
if total ………………………

The above program is not very efficient as it stands.


You have been asked to redesign the program using an unbounded loop.

a) Explain why a loop is useful in this case and why an unbounded loop would be 3
most appropriate.

b) Write pseudocode that implements the above program using a loop. 5

c) Explain how a bounded loop differs from an unbounded loop. 2

Total 10 Marks

Question 6

a) Below is a grid representing data in memory.

columns
0 9
0
rows

i) Declare a two-dimensional array to represent the above grid. Assume that 2


each cell of the grid represents a whole number.

Questions continue next page

Page 5 of 8
Software Development Techniques © NCC Education Limited 2022
ii) Set the element highlighted in the grid to -1. 2

b) The following function accepts a single number as a parameter. 4

It checks to see if the number is a positive number or not.

Parts of the program are missing.

You need to identify the missing parts.

Function IsPositive (……… p as whole number) ……… Boolean


Data result as Boolean

result = false
If p is ……… than or equal to 0 then
result = true
end if
……… result
End function

c) Complete the following sentences.

i) When we pass an array to a function we do not specify its ………… . 1

ii) The logical operator ………… means either condition must be true to give a 1
result of true.

Total 10 Marks

Question 7

a) Searching and sorting of data is an important aspect of computing

i) Explain the difference between searching and sorting. 2

ii) An algorithm that scales well is one that does not significantly increase the 4
time it takes to complete as data increases.

The following are big O notations that represent how well algorithms scale.

O(n2), O(1), O(log n), O(n)

Identify the best and the worst scaling.

Explain your reasons for your choice.

Questions continue next page

Page 6 of 8
Software Development Techniques © NCC Education Limited 2022
b) Fill in the missing words below:

i) The simplest kind of search is the ………… search. 1

ii) ………… searching requires an ordered array to work. 1

iii) The simplest form of sorting is known as ………… sorting. 1

iv) ………… splits an array into sub-arrays and sorts each individually. 1

Total 10 Marks

Question 8

a) Below is a logical equation: 4

R = NOT ((P AND Q) OR (P OR Q))

Copy and fill in the truth table below for the above equation.

P Q P AND Q P OR Q R
F F
F T
T F
T T

b) A simple logic circuit has TWO (2) inputs A and B, and TWO (2) outputs C and D. 4

The inputs and the outputs are defined as following

C = NOT A AND B
D = NOT C

Draw a truth table that represents the logic of the above circuit for all combinations
of the inputs A and B.

c) Write a single if statement in pseudocode that does the following: 2

Sets the value of variable var1 to ONE (1) if the value of variable var2 is higher
than ZERO (0).

Sets the value of variable var1 to ZERO (0) if the value of variable var2 is not
higher than ZERO (0).

Total 10 Marks

Questions continue next page

Page 7 of 8
Software Development Techniques © NCC Education Limited 2022
Question 9

a) Complete the missing parts of the following statements:

i) Efficient algorithms do what they need to do in the ……………. lines of code. 1

ii) Loops within loops are called ……………. loops. 1

iii) Variables which are made up of other variables are ……………. data types. 1

iv) Iteration is another word for ……………. . 1

v) Calling a function means ……………. the function. 1

vi) Objects are created using the ……………. keyword. 1

b) Write a function in pseudocode that accepts ONE (1) parameter of type whole 4
number.

The function prints the string “Yes” if the number is a negative number or prints the
string “No” if it is a positive number.

Total 10 Marks

Question 10

a) In the following program various variables with different data types are declared.

These variables are then assigned values, but the programmer made a mistake
and assigned the values to the wrong variables.

Data a as string
Data b as whole number
Data c as real number
Data d as Boolean
Data e as character

a = 123
b = 1.23
c = “Hey”
d = ‘M’
e = True

i) Re-write the assignments, assigning the values to the correct variables. 5


You must use the same values as above.

ii) Explain why you made each correct assignment. 5

Total 10 Marks
End of paper
Page 8 of 8
Software Development Techniques © NCC Education Limited 2022

You might also like