How to test an algorithm

Now that you have written a computer algorithm how will you check if it produces the desired results or not? The only way is to run the algorithm and see the results. And this is something you can easily do manually by going through the algorithm step by step.

How to run through an algorithm

When you have to test an algorithm you should read it step by step and try to find out its output. Only if you get the desired output the algorithm will be considered as correct. Let’s take an example. Look at the algorithm below


Step1 : Take two variables A and B
Step2: Set A = 5
Step3 : Step B = 10
Step4 : Take a variable C
Step5 : Set C = A + B
Step6 : Set C = C – B
Step7 : Print C


Now try to run the above algorithm and try to find the value which will be printed at the end. In Step2 and Step3 we are simply setting value of variables A and B as 5 and 10. In Step4 we have created a new variable C. In Step5 we are adding A and B and putting the result in C. In Step6 we are subtracting the value of B from C and setting it back to C. So after Step6 the value in C will be the same as A. In Step7 when you print C you will get the value of A, which in this case is 5.

With more practice you will be able to find the result of even complex algorithms by running them manually.

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp