0% found this document useful (0 votes)
3 views9 pages

Testing Algorithms

NOtes on Testing Algorithms

Uploaded by

nrssgy edpmandit
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)
3 views9 pages

Testing Algorithms

NOtes on Testing Algorithms

Uploaded by

nrssgy edpmandit
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
You are on page 1/ 9

TESTING ALGORITHMS

ALGORITHMS
TESTING ALGORITHMS

Before you convert an algorithm to code, it


is a good idea to check that it is complete
and logical. This can be done by using
actual values on the algorithm. There are
two ways to do this: DRY–RUN
TESTING and TRACE TABLES.
DRY–RUN TESTING

 Dry-run testing is also known as desk


checking. This is when you substitute values
for the variables and follow the instructions
in the algorithm step by step to arrive at a
solution.
 A dry-run test will tell you if there are any

logic errors in your algorithm.


DRY–RUN TESTING
TRACE TABLES

 Trace table is a very useful tool which


allows you to see the state of your algorithm
with as much detail as you wish.
 They are tables that track each variable as

it progresses through the calculation.


 It will show you the output of each cycle of

calculation within a problem.


TRACE TABLES
Example
Number1 = 0
Number2 = 1
While Number1 < 12 Do
Number1 = Number1 + 3
Number2 = Number2 + 2
Print Number1, Number2
EndWhile
TRACE TABLES
Number1 Number2 Output
0 1 -
3 3 -
6 5 -
9 7 -
12 9 Number 1 =12,
Number2 = 9
Explanation

 The first step is to create a table with


a column for each variable and one
row per pass,
 so the number of rows depends on

how many times the calculations is


carried out.
Explanation
 The first row contains the initialised values
 The second row contains the values of Number1 after
3 is added to it and the value of Number2 after 2 is
added to it. Number1= 3 and Number2 = 3.
 The third row contains Number1= 6 and
Number2 = 5.
 Fourth row contains Number1= 9 and Number2 = 7 .
 Fifth row contains Number1= 12 and Number2 = 9.
 The loop stops after number reaches 12.

You might also like