0% found this document useful (0 votes)
4 views3 pages

Algorithm PS

The document contains a series of model tests focused on programming concepts, including flowchart symbols, test data examples, algorithm writing in pseudocode, and validation checks. Each test is structured with specific tasks that require explanations, code snippets, and algorithm design. The tests cover various scenarios such as a vending machine, weather station, library kiosk, rollercoaster height check, and exam result processing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Algorithm PS

The document contains a series of model tests focused on programming concepts, including flowchart symbols, test data examples, algorithm writing in pseudocode, and validation checks. Each test is structured with specific tasks that require explanations, code snippets, and algorithm design. The tests cover various scenarios such as a vending machine, weather station, library kiosk, rollercoaster height check, and exam result processing.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Algorithm Practice Sheet

Model Test 1: The Vending Machine (10 Marks)

Background: A programmer is designing software for a new school vending machine.

• (a) [1 mark] The programmer draws a flowchart. What shape should they use to
represent the machine outputting a "Sold Out" message?
• (b) [2 marks] The vending machine only accepts coin values from 5 cents up to 50 cents.
Give one example of Abnormal (Erroneous) test data and one example of Extreme test
data for this rule.

• (c) [3 marks] Before writing the code, the programmer uses Decomposition and
Abstraction. Briefly explain what both of these terms mean in computer science.

• (d) [4 marks] Write an algorithm in pseudocode that uses a FOR...TO...NEXT loop to


input the prices of exactly 5 snacks, calculates the total price of all 5 snacks, and outputs
the final total at the end.

Model Test 2: The Weather Station (10 Marks)

Background: A digital weather station records the temperature once every hour.
• (a) [1 mark] The programmer wants to ensure that the inputted temperature is between -
50°C and 50°C. State the name of the validation check used for this.
• (b) [2 marks] Give the two pieces of Boundary Data needed to test the upper limit of
the -50°C to 50°C rule.

• (c) [3 marks] The programmer writes an algorithm to find the lowest temperature of the
day. They set the starting variable to MinimumTemp <- 0. Explain why this is a logical
error, and state what they should do instead to fix it.

• (d) [4 marks] Write an algorithm in pseudocode that asks the user to INPUT
Temperature. Use a REPEAT...UNTIL loop to keep asking for a temperature until the
user types "-99" to shut the system down. Keep a running count of how many
temperatures were entered, and output the count at the end.
Model Test 3: The Library Kiosk (10 Marks)

Background: A school library uses a self-service kiosk to check out books and search the
database.

• (a) [1 mark] A student searches for a book. What is the name of the standard search
algorithm that inspects each item in a list in turn until it finds a match?

• (b) [2 marks] When a student creates a new PIN code, the system uses Double Entry.
State whether this is Validation or Verification, and explain why it is used.

• (c) [3 marks] The programmer writes a WHILE...DO loop. Explain why a WHILE loop
might never run its code, whereas a REPEAT...UNTIL loop will always run at least once.

• (d) [4 marks] The programmer wrote this inefficient code to check a book's category:

Code snippet

IF Category = "F" THEN OUTPUT "Fiction" ENDIF

IF Category = "N" THEN OUTPUT "Non-Fiction" ENDIF


IF Category = "R" THEN OUTPUT "Reference" ENDIF

Rewrite this code to be more efficient by using a CASE OF...OTHERWISE...ENDCASE


statement. Include a safety net that outputs "Unknown" if they type a wrong letter.

Model Test 4: The Rollercoaster (10 Marks)

Background: A theme park has a height-checking scanner at the entrance of a rollercoaster.

• (a) [1 mark] The programmer uses Top-Down Design to break the system into sub-
systems. What is the technical name for the process of breaking down sub-systems until
each performs a single action?

• (b) [2 marks] Name two of the four main component parts (pillars) of any computer
system.

• (c) [3 marks] Look at the following pseudocode:

Code snippet

Tickets <- 5

WHILE Tickets > 0 DO


OUTPUT Tickets
Tickets <- Tickets - 2

ENDWHILE

Create a simple trace table with two columns (Tickets and OUTPUT) and dry-run this code to
show what is printed to the screen.

• (d) [4 marks] Write an algorithm in pseudocode that asks the user to INPUT Password.
Use a WHILE...DO...ENDWHILE loop. While the password is NOT equal to
"Secret123", output the message "Access Denied" and ask them to input the password
again.

Model Test 5: The Master Challenge (10 Marks)

Background: A school is processing the exam results for a class of students.

• (a) [1 mark] Barcodes and ISBN numbers have an extra number at the very end
calculated from the other numbers to catch typos. What is this digit called?

• (b) [2 marks] The system needs to ensure the student's phone number contains no letters,
and that it is exactly 10 numbers long. Name the two validation checks needed.

• (c) [3 marks] The following pseudocode has 3 errors. Identify all three errors.

Code snippet

Total <- 0
FOR Counter <- 1 TO 10

INPUT Score

Total <- Total + Counter

OUTPUT Total

NEXT Score

• (d) [4 marks] Write an algorithm in pseudocode that uses a FOR...TO...NEXT loop to


input the scores of exactly 20 students. Use an IF statement inside the loop to check if the
score is greater than 80. Keep a running count of how many students scored over 80, and
output the final count at the end.

You might also like