Efficiency of Algorithms
Efficiency of algorithm depends on design and implementation of algorithm. Algorithm uses computer resources to complete its task. An efficient algorithm is judged by the factor as to how economically and efficiently the CPU time and memory are used.
Characteristics of Efficient Algorithms
1) Algorithms should be efficient and economical in use of computer time, memory and peripherals.
2) They should be simple and most generalized.
3) They should be easily understandable and clear for implementation.
4) They can be easily modified if necessary.
5) They should be well documented for to be used by those who do not have knowledge of their inner working.
6) They should not be dependent for running on a particular computer.
7) It should be possible to use them to as a sub procedure for other problems.
Causes of Inefficiency
There are many reasons due to which the efficiency of a programme decreases. Some of them are described below.
1. Redundant computation
One of the main causes of inefficiency is redundant computation. When redundant computation is done inside a loop it reduces the efficiency considerably. The most common mistake is computing few expressions inside the loop which can be stated out of loop. The following example illustrates the point:
Let us consider 'x', 'i' as temporary variables and 'n' as input from the user and 'a','b', 'c' are constants.
x = 0;
i = 0;
a = 3.2;
b= 4.0;
c = 5.8;
while (i < n)
{
x = x + 0.1;
y = (a*a*a+c) *x*x+b*b*x;
printf('x = %f y = %f', x, y);
i = i +1;
}
In this loop there is unnecessary computation like multiplication and addition of constant terms 'a', 'b' and 'c' which can be computed outside the loop also, which is given below
a3c= a*a*a+c;
b2 = b*b;
For (i= 0; i<n;i++)
y = a3c *x*x+b2*x;
printf('x = %f y = %f', x,y);
2. Late termination
Doing more conditional checks or tests inside the loop is called late termination. For example we have a sorted list of names. We need to find the name JAGJIT. The name may exist in the list or may not. A common mistake committed here is searching till the end of the list. Instead one can search till a name occurs which is alphabetically later then JAGJIT like JASWANT. If the name JAGJIT exists in the list, the loop should terminate as soon as the name is found. This is illustrated with the algorithms below.
3. Inefficient algorithm
while name sought <> Current name and till end of file do get next name from list
Efficient algorithm
while name sought <> Current name and till end of file do
a) get next name from list
b) If current name is greater than the name sought exit from the loop
4. Early determination of desired output
Sometimes it may happen that the required output may be achieved before termination condition occurs. For example in an algorithm for sorting a list of items, assume the list is already sorted. Performing the entire sorting is inefficient in this case as it is already sorted? Predetermination of the fact the list is already sorted can reduce computation. Checking whether there is any exchange in each pass and terminating the loop in case of no exchanges can reduce the iterations.
5. Storage and inefficiency
Storage is one the main factors of efficiency. Avoid using lot of intermediate storage which are not much used later in the program Try to use dynamic storage (allocating memory as and when required) as much as possible which avoids excessive allocation of memory. Free the memory of unnecessary variables after their use in the program.
the discovery of vcrs made it simple to rent or purchase movies and watch them at home, but tvs just did not compare to movie theatres’ giant screens and surround-sound systems.
tutorsglobe.com importance of money assignment help-homework help by online money tutors
tutorsglobe.com role of bacteria in industry assignment help-homework help by online beneficial activities of bacteria tutors
Hire skilled tutors 24/7 with the prominent Cartography Assignment Help at pocket-friendly prices and secure your dream grades!
Low and High Frequency Power Amplifiers tutorial all along with the key concepts of Amplifier specifications, Linearity, Output Dynamic Range, Slew Rate, Stability, Power electronic amplifiers, High frequency power amplifier, Radio Frequency
Find Environmental Health Assignment Help and get top-notch solutions from top-rated tutors available 24x7!
tutorsglobe.com carboxylation reactions assignment help-homework help by online c3 and c4 pathways tutors
Theory and lecture notes of Creating an Ogive all along with the key concepts of Creating an ogive, Relative frequency of ogive, homework help and assignment help. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Creating an Ogive.
Theory and lecture notes of Integration-Left, Right and Trapezoid Rules all along with the key concepts of functions and data, Left and Right endpoint rules, Trapezoid rule, Trapezoid rule for areas in the plane. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Integration-Left, Right and Trapezoid Rules.
Theory and lecture notes of Response mode processing all along with the key concepts of response mode processing, data communication. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Response mode processing.
tutorsglobe.com endocytosis and exocytosis assignment help-homework help by online cell membrane tutors
periodic table-classification of elements tutorial all along with the key concepts of periodic law, description of the periodic table, groups of periodic table and transition elements
Measurement of Temperature tutorial all along with the key concepts of Heat and Temperature, Types of Temperature Scales, Conversion Formulas, Constant Volume Gas Thermometer Scale, Standard Thermometer Scale, Types of Thermometer and Optical Pyrometers
online regents exam preparation course and online regents tutoring package offered by TutorsGlobe are the most comprehensive and customized collection of study resources on the web, offering best collection of regents practice papers, quizzes, regents test papers, and guidance.
General Embryology tutorial all along with the key concepts of Gametogenesis, Kinds of Egg Membranes, Fertilization, Mechanism of Fertilization, Cleavage, Kinds of Cleavage, Planes of Cleavage, Patterns of Cleavage, Blastulation, Gastrulation and Organogenesis
1951893
Questions Asked
3689
Tutors
1463459
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!