Chapter 3
Chapter 3
Chapter 3
Chapter Summary
Algorithms
Example Algorithms
Algorithmic Paradigms
Growth of Functions
Big-O and other Notation
Complexity of Algorithms
Algorithms
Section 3.1
Section Summary
Properties of Algorithms
Algorithms for Searching and Sorting
Greedy Algorithms
Halting Problem
Problems and Algorithms
In many domains there are key general problems that
ask for output with specific properties when given
valid input.
The first step is to precisely state the problem, using
the appropriate structures to specify the input and the
desired output.
We then solve the general problem by specifying the
steps of a procedure that takes a valid input and
produces the desired output. This procedure is called
an algorithm.
Algorithms Abu Ja’far Mohammed Ibin Musa Al-Khowarizmi
(780-850)
At the first pass the largest element has been put into the correct position
At the end of the second pass, the 2 nd largest element has been put into the correct position.
In each subsequent pass, an additional element is put in the correct position.
Insertion Sort
Insertion sort begins with the 2nd element. It compares the 2nd element
with the 1st and puts it before the first if it is not larger.
procedure insertion sort
•Next the 3rd element is put into the (a1,…,an: