SD Pseudocode Error Questions-Mk
SD Pseudocode Error Questions-Mk
Peter has found that the code follows the algorithm below.
Begin
If Temperature > MaxTemp Or Light >MaxLight Then
CurtainMotor (Close)
Endif
If Temperature < MinTemp Or Light < MinLight Then
CurtainMotor (Open)
Endif
End
a. Below is a testing table. Work out the action that the algorithm finally produces and complete the last
column.
4 marks
b. A line in the algorithm contains a logic error. Identify that line by writing it out in full. 1 mark
Kayla has completed her analysis of the system. She has decided to start the design of the new system with the
design of the software. From her analysis she knows that one thing the system has to do is to calculate the
required amount of each ingredient.
She designs an algorithm that
reads a file to get the total number of different ingredients Sebastian keeps in stock
(Num_Ingredients)
for each bread item (Product_ID) ordered, uses recipe data and the number of items ordered (Num _
Ord) to
calculate the amount of each ingredient required for that item (Amount_ Req)
adds the ingredient amounts required for each item to get the total quantity needed for each
ingredient Qty ()
Question 3
a. What is the purpose of the first REPEAT - UNTIL loop? (1 mark)
To test the algorithm Kayla decides to use some simplified test data with only 1 bread product and only 3
ingredients.
Note: Why is the indexing of the array reversed? It should be (1,3) for example - product 1, ingredient 3. That's
the order it is in the algorithm. (Note: this has been confirmed as a rare booboo by the SD exam writers. It's not
significant to the answers, however.)
i. What output would you expect to get if the algorithm was correct? 2 marks
ii. What output does the algorithm actually give? 2 marks
b. Describe the error in the algorithm. 2 marks
c. Suggest one way the algorithm could be altered to fix this error.2 marks
Question 6
From the variables used in the algorithm, select one of each type to complete the following table.
Member ID numbers must be between 1 and fifty thousand (50 000). When a new member is added, the
program uses the following code to generate a new member ID number.
where rand( ) returns a six-digit random number between zero and one, and
If a new member is being added and rand( ) returns 0.002222 then Member ID will be set to
A. 2
B. 12
C. 112
D. 1112
Question C7
During her analysis of the system, Rose interviewed all the assemblers in the Melbourne factory. One
assembler mentioned that sometimes RoboCut would reject a good piece of timber.
Rose investigates this and finds that the problem started after the last software upgrade six months ago. She
contacts MyCut and it claims that none of its other users have reported this problem. After some argument
MyCut agrees to send Rose the algorithms related to the software changes. She finds one algorithm that has to
do with the cutting process. RoboCut uses this algorithm to check whether or not a piece of timber is long
enough to use.
Rose decides to test this algorithm by choosing a length of timber (Timber_Length) of 2.4 metres. For the other
variable (Length_Required) she chooses the values 2.3, 2.4 and 2.5.
b. Complete the following table showing what the algorithm should return and what it actually returns. (2)
c. Explain why RoboCut only sometimes rejects a good piece of timber. (1)
d. State one alteration to the algorithm that would correct this error. (1)
Question 6
When the above algorithm was tested it was found that it did not provide the correct result when T=20. This
was caused by a
A. logic error.
B. syntax error.
C. run time error.
D. compile time error.
Question C9
During the trial it was found that when nurses changed their passwords for the portable devices the program
failed and they were locked out. Investigation found that entering certain characters caused the problem, so it
was decided to limit the passwords to just alphabetic letters and numbers. Suzie has suggested the algorithm
below to validate a new password before it is stored in the system. She must now test it.
b. Suggest one other item of data that will test another aspect of the password procedure and explain why it
should also be used.
Question 10
Suzie found her algorithm does not produce the output expected.
b. Explain why the algorithm is giving the wrong output. (2)
c. Explain how the algorithm could be corrected. (3)