1 is not a generalized one because in step 6 it

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: inds difficult to appreciate. Quality of Algorithms Given a solvable problem, there are often many methods to solve it. All of these methods may not be equally good. Similarly, for a given problem, there may be many algorithms, not all of equal quality. The primary factors that are often used to judge the quality of an algorithm are: 1. Time requirement. This is the time required to execute the corresponding program on a given computer system. The lesser is the time requirement, the better is the algorithm. 2. Memory requirement. This is the memory space required to execute the corresponding program on a given computer system. The lesser is the memory requirement, the better is the algorithm. 3. Accuracy of solution. Although multiple algorithms may provide correct solutions to a given problem, some of these may provide more accurate results than others. For example, out of two algorithms for calculating the square root of a given number, one might have been designed to produce results up to three decimal places, while the other one might have been designed to produce results up to six decimal places. Obviously, the latter algorithm is better from the point of view of accuracy of solution. 4. Generality. While there are occasions when an algorithm is needed to solve a single isolated problem, more often algorithms are designed to handle a range of input data. A generalized algorithm, which can handle a range of input data, is better than one, which has been designed to solve a problem for a single input data. For instance, the algorithm given above for Example 11.1 is not a generalized one because in Step 6 it checks if Total_Marksheets_Checked has become equal to 50. Hence it will work only if there are exactly 50 students data as input. The algorithm can be made general by accepting the number of students (iV) as input and then comparing the value of Total_Marksheets_Checked with JV instead of 50 in Step 6. Representation of Algorithms There are various ways in which an algorithm can be represented. Programmers normally use one or more of the following ways to represent their algorithms: 1. As...
View Full Document

Ask a homework question - tutors are online