← Back to Articles

Desk Checking

Jamie Z 2024-02-08

Learning Goals

  • Understand the Desk Checking process
  • Be able to apply it to algorithms
  • Use positive and negative use cases to thoroughly desk check an algorithm

What is Desk Checking

Desk checking is a manual technique for verifying the accuracy of an algorithm, typically by tracing through an example by hand and writing down the intermediate values. This can be useful for catching syntax and logic errors, as well as helping to understand how the algorithm works.

Desk Checking Steps

  1. Choose two or three simple input test cases that are valid
  2. Ensure you have the correct results for each test case
  3. Make a trace table with relevant variable names in each column
  4. Walk through the first test case, recording the step-by-step values of the variables
  5. Repeat this for each set of test data and ensure correct results are output

Step By Step

Problem

  • We need to construct an Algorithm to Calculate the Discount Price of an item

Algorithm

1 BEGIN displayGrade()

2  INPUT mark

3          IF mark > 50 THEN

4          grade = “C”

5          OUTPUT “Good work”

6  ELSE IF mark > 65 THEN

7  grade = “B” 

8  OUTPUT “Great work”

9  ELSE IF mark > 85 THEN

10  grade = “A”

11  OUTPUT “Excellent work”

12  ELSE

13         grade = “Fail”

14  ENDIF

15  OUTPUT grade

16  END

Desk Checking

Test Data = 51

Line Grade Mark Conditions Input/Output
1
2 51 51
3 If mark > 50
4 C
5 “Good Work”
"C”

Test Data = 80

Line Grade Mark Conditions Input/Output
1
2 80 80
3 If mark > 50
4 C
5 “Good work”
“C”