Lec 01 22 01 17
Lec 01 22 01 17
1
Material for the presentation taken from Cormen, Leiserson, Rivest and
Stein, Introduction to Algorithms, Third Edition; 1
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
CS F211: Data Structures and Algorithms
Handout Discussion
2
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
� Sorting Problem
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
� Sorting Problem
Input: A sequence of n numbers < a1 , a2 , . . . , an >
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
� Sorting Problem
Input: A sequence of n numbers < a1 , a2 , . . . , an >
Output: A permutation < a1� , a2� , . . . , an� > such that
a1� ≤ a2� ≤ · · · ≤ an�
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
� Sorting Problem
Input: A sequence of n numbers < a1 , a2 , . . . , an >
Output: A permutation < a1� , a2� , . . . , an� > such that
a1� ≤ a2� ≤ · · · ≤ an�
� E.g., Input sequence : < 31, 41, 59, 26, 41, 58 >
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
� What is an Algorithm?
It is a well-defined computational procedure which takes an
input and produces an output.
� An algorithm solves a computational problem.
� Sorting Problem
Input: A sequence of n numbers < a1 , a2 , . . . , an >
Output: A permutation < a1� , a2� , . . . , an� > such that
a1� ≤ a2� ≤ · · · ≤ an�
� E.g., Input sequence : < 31, 41, 59, 26, 41, 58 >
� Sorting algorithm should give the output:
< 26, 31, 41, 41, 58, 59 >
3
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
4
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Role of algorithms in computing
5
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Which Algorithm should be preferred?
5
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Which Algorithm should be preferred?
5
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Which Algorithm should be preferred?
5
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Which Algorithm should be preferred?
5
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
6
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Efficiency of Algorithms
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
7
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Importance of efficiency
8
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms
Comparison of running times
9
BITS-Pilani K. K. Birla Goa Campus Data Structures and Algorithms