Lecture 1 - Introduction to Design and analysis of algorithms
What is an algorithm?
Algorithm is a set of steps to complete a task.
Task: to make a cup of tea.
add water and milk to the kettle,
boilit, add tea leaves,
Add sugar, and then serve it in cup.
What is Computer algorithm?
‘’a set of steps to accomplish or complete a task that is described precisely enough that a
computer can run it’’.
Described precisely: very difficult for a machine to know how much water, milk to be added
etc. in the above tea making algorithm.
These algorithmsrun on computers or computational devices.Forexample, GPS in our
smartphones, Google hangouts.
GPS uses shortest path algorithm. Online shopping uses cryptography which uses RSA
Characteristics of an algorithm:•
Must take an input.
Must give some output(yes/no,valueetc.)
Definiteness –each instruction is clear and unambiguous.
Finiteness –algorithm terminates after a finite number of steps.
Effectiveness –every instruction must be basic i.e. simple instruction.