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

After this dry-run we understand that this pseudocode is only going to work if the test data is within the

range of 0-100

Drawback: This is the drawback of this pseudocode. Any other values outside 0-100 range will not be
identified. It will not work for test data less than 0 like the negative values.

How we can correct it?

Change the range values i.e. initial values of B and C


After changing the range

In this case we set B=-1000000 and C=100000

Now if our test data is: -100001, -100002, -100006

So at the end, output will be -100000,-100006

The problem here is that B does not have the largest value from test data. It has that initial value that
we had set. So this pseudocode is not identifying largest value in this test data.

If our test data is: 100005, 100008, 100007

And so at the end, our output will be 100008,100000

The problem here is that C did not identify the smallest value in the test data. It has the initial value
100000 for comparison and so this pseudocode doesn’t identify smallest value smaller than 100000
The above changed/ amended algorithm will work perfectly for any test data!

You might also like