Module 1 Algorithm
Module 1 Algorithm
Properties of Algorithm
➢ Non Ambiguity
Each step in an algorithm should be non-ambiguous. That means each instruction
should be clear and precise. This property also indicates the effectiveness of
algorithm.
➢ Range of Input
The range of input should be specified.
➢ Multiplicity
The same algorithm can be represented into several different ways.
➢ Speed
The algorithm is written using some specified ideas. Bus such algorithm should be
efficient and should produce the output with fast speed.
➢ Finiteness
The algorithm should be finite. That means after performing required operations it
should be terminate.
Algorithm Analysis
Efficiency of an algorithm
• Time complexity
• Space complexity
Time Complexity:
1. Instruction Space
• It's the amount of memory used to save the compiled version of instructions.
2. Environmental Stack
3. Data Space
Classification of algorithms
• A space -time trade off can be applied to the problem of data storage.
• If data is stored uncompressed,it takes more space but less time.
• If the data is stored compressed, it takes less space but more time to run the
decompression algorithm.
• Storing only the source and rendering it as an image everytime the page is requested
would be trading time for space. More time used but less space.
• Storing the images would be trading space for time. More space used but less time.
• Smaller code occupies less space in memory but it requires high computation time
which is required for jumping back to the beginning of the loop at the end of each
iteration.
• Larger code or loop unrolling can be traded for higher program speed. It occupies
more space in memory but requires less computation time. (as we need not perform
jumps back and forth since there is no loop.)