CSC 305 VTL Lecture 01
CSC 305 VTL Lecture 01
1
Content
• Introduction to Algorithm and Complexity
• Types of algorithms
• Algorithm design methodologies
• Sorting algorithms
• Theoretical analysis of algorithms
• Order of growth and Asymptotic notations
• Time efficiency of algorithms
• Polynomial order of algorithms
Reading Texts
• Introduction to Algorithms, (The MIT Press) by Thomas H. Cormen,
Charles E. Leiserson, Ronald L. Rivest and Clifford SteinA
• The Algorithm Design Manual by Steven S S. Skiena (Author)
• Algorithm Design by Jon Kleinberg
1.0Introduction to Algorithm
Definitions:
• An algorithm is any well-defined computational procedure that takes some
value, or set of values, as input and produces some value, or set of values,
as output.
• An algorithm is thus a sequence of computational steps that transform the
input into the output.
• An algorithm can also be seen as a computational logic
• We can also view an algorithm as a tool for solving a well-specified
computational problem.
• An algorithm describes a specific computational procedure for achieving
that input/output relationship
An algorithm is a finite set of instructions that, if followed, accomplishes a
particular task.
Introduction to Algorithm….
All algorithms must satisfy the following criteria:
(1) Input. There are zero or more quantities that are externally
supplied.
(2) Output. At least one quantity is produced.
(3) Definiteness. Each instruction is clear and unambiguous.
(4) Finiteness. If we trace out the instructions of an algorithm, then for
all cases, the
algorithm terminates after a finite number of steps.
(5) Effectiveness. Every instruction must be basic enough to be carried
out
Introduction to Algorithm
Computational complexity is the study of the cost of solving interesting problems.
It is the measure of the amount of resources needed in solving problems.
The major resources usually considered are:-
➢Time
➢Space
Algorithm analysis = Analysis of the resources usage of given algorithms
Targets:
❖Make resources usage to be of polynomial order
❖Make that polynomial as small as possible
Avoid:
Exponential order
ie. Polynomial is good, while exponential is bad
Introduction to Algorithm (contd….)
For example, we might need to sort a sequence of numbers in ascending order. This problem
arises frequently in practice and provides fertile ground for introducing many standard design
techniques and analysis tools. Here is how we formally define the sorting problem:
Output: A permutation (reordering) (a’1 a’2, ….. a’n) i of the input sequence such
1
For example, given the input sequence {31; 41; 59; 26; 41; 58}, a sorting algorithm
returns as output the sequence {26; 31; 41; 41; 58; 59}. Such an input sequence is
called an instance of the sorting problem. In general, an instance of a problem
consists of the input (satisfying whatever constraints are imposed in the problem
statement) needed to compute a solution to the problem.
Introduction to Algorithm (contd….)
The major goal of this course is to develop techniques for developing efficient algorithms.