0% found this document useful (0 votes)
35 views

1 - Algorithm Analysis

The document discusses the syllabus and topics for an algorithms course, including algorithm analysis, asymptotic notations, algorithm design techniques like divide and conquer, greedy algorithms, and dynamic programming. Specific applications and examples are provided for each topic.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

1 - Algorithm Analysis

The document discusses the syllabus and topics for an algorithms course, including algorithm analysis, asymptotic notations, algorithm design techniques like divide and conquer, greedy algorithms, and dynamic programming. Specific applications and examples are provided for each topic.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Syllabus of Algorithms:

➢ Searching
➢ Sorting
➢ Hashing
➢ Asymptotic worst case time and space complexity.
➢ Algorithm design techniques:
 Greedy,
 Dynamic programming and
 Divide-and-conquer.
➢ Graph search
➢ Minimum spanning trees
➢ Shortest paths.

SUBJECT: Algorithms
Schedule:
➢ Introduction and Analysis of algorithm
➢ Solving recurrence relations:
(i) Substitution method
(ii) Recursive tree method
(iii) Master’s theorem
➢ Asymptotic Notations
➢ Algorithm Design Techniques:
(i) Divide and Conquer
(ii) Greedy Technique
(iii) Dynamic Programming
➢ Sorting
➢ Graph Traversals
➢ Hashing

SUBJECT: Algorithms
Applications:
➢ Divide and Conquer ➢ Greedy Technique
(i) Power of an element (i) Greedy Knapsack
(ii) Selection Procedure (ii) Job sequencing with deadline
(iii) Binary Search (iii) Minimum cost spanning tree
(iv) Find max and min element. (iv) Huffman coding
(v) Strassen’s matrix multiplication (v) Optimal merge pattern
(vi) Quick sort (vi) Single source shortest path
(vii) Merge sort ➢ Dynamic Programming
➢ Sorting (i) Longest common subsequence
Insertion sort (ii) Multistage graph
Bubble sort (iii) 0/1 knapsack
Selection sort (iv) Travelling salesman problem
Heap sort (v) Multistage graph
(vi) All pairs shortest path
SUBJECT: Algorithms
Introduction to Algorithms

SUBJECT: Algorithms
Definition of an algorithm-
➢ An algorithm is a finite set of instructions that, if followed, accomplishes a
particular task.

➢ An algorithm is a sequence of computational steps that transform the input into


the output.

➢ An algorithm is an abstraction of a program to be executed on a physical machine


(model of computation).

➢ Algorithm is a well-defined procedure which will take a set of values (0 or more)


as input and produces a set of values (1 or more) as output.

SUBJECT: Algorithms
Algorithms must satisfy the following :
➢ Input : Number and types of required inputs.

➢ Output : Results must be specified.

➢ Definiteness : Each instruction should be clear and unambiguous.

➢ Finiteness : The algorithm should terminate after finite number of steps.

➢ Effectiveness : Every instruction must be very basic.

SUBJECT: Algorithms
Algorithm Development stages :
➢ Requirements: make sure that we understand the information that is given.

➢ Design: write an algorithm which solves the problem according to the


requirements.

➢ Analysis: choose if more than one algorithm exists.

➢ Refinement and coding

➢ Verification

SUBJECT: Algorithms
Analysis of an algorithm
➢ Analysis of algorithms refers to the task of determining how much computing
time and storage an algorithm requires.

➢ This can be done in two ways:

1. Priori Analysis: This is done before the execution.

2. Posteriori Analysis: This analysis is done after the execution.

SUBJECT: Algorithms
Analysis of an algorithm

SUBJECT: Algorithms
Analysis of an algorithm
(A) Fun()
{
for(i=1;i<n; i=3i);
X = Y + Z;
}

(B) foo()
{
i = n;
while(i>1)
i= i/2;
}

SUBJECT: Algorithms
Analysis of an algorithm

(B) foo()
{
i = n;
while(i>1)
i= i/2;
}

SUBJECT: Algorithms
SUBJECT: Algorithms
Analysis of an algorithm
foo()
{
n = 2^2^k where k is a positive integer
for( i=1; i<=n; i++)
{
j=2;
while(j<=n)
j=j^2;
}
}

SUBJECT: Algorithms
GATE-2017
Consider the following C function Time complexity of fun in terms of θ
int fun(int n) notation is:
{ (a) θ(n √n)
(b) θ(n2)
int i, j; (c) θ(n log n)
for(i=1; i<=n; i++) (d) θ(n 2 log n)
{
for (j=1; j<n; j+=i)
{
printf("%d %d", i, j);
}
}
}

SUBJECT: Algorithms
GATE-2015:

Consider the following C function. Which one of the following most closely
int fun1 (int n) approximates the return value of the function
{ fun1?
(A) n3
int i, j, k, p, q = 0; (B) n (logn)2
for (i = 1; i<n; ++i) (C) nlogn
{ (D) nlog(logn)
p = 0;
for (j = n; j > 1; j = j/2)
++p;
for (k = 1; k < p; k = k*2)
++q;
}
return q;
}
SUBJECT: Algorithms
GATE-2013
Consider the following function
int unknown(int n)
{
int i, j, k = 0;
for (i = n/2; i <= n; i++)
for (j = 2; j <= n; j = j * 2)
k = k + n/2;
return k;
}
What is the returned value of the above function?
(a) θ(n2)
(b) θ(n 2 log n)
(c) θ(n3)
(d) θ(n 3 log n)

SUBJECT: Algorithms
GATE-2007/ ISRO-2016:
Consider the following segment of C-code:

int j, n;
j = 1;
while (j <= n)
j = j*2;
The number of comparisons made in the execution of the loop for any n > 0 is:

Base of Log is 2 in all options.


(A) CEIL(logn) + 1
(B) n
(C) CEIL(logn)
(D) FLOOR(logn) + 1

SUBJECT: Algorithms
Glimpse of Next Session:
➢ Asymptotic Notations
➢ Comparison of Functions

SUBJECT: Algorithms
Any Queries????

SUBJECT: Algorithms
Syllabus:
➢ Algorithm Analysis

➢ Asymptotic Notations

➢ Divide and Conquer (Finding max min element, binary search, Quick sort, Merge sort, Selection
Procedure, Strassen’s Matrix Multiplication).

➢ Greedy Technique (Greedy Knapsack, Job sequencing with deadline, Huffman coding, Optimal
merge pattern, Minimum cost spanning tree, Single source shortest path)

➢ Dynamic Programming (0/1 knapsack, LCS, Multistage graph, MCM, TSP, All pairs shortest
path, SOS, Optimal cost binary search tree).
➢ Sorting
➢ Hashing

SUBJECT: Algorithms

You might also like