You are on page 1of 35

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
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
Asymptotic Notations:
Asymptotic notation is a shorthand way to write down and talk about ‘fastest
possible’ and ‘slowest possible’ running times for an algorithm using high and low
bounds on speed.
These are also referred as ‘best case’ and ‘worst case’ scenarios respectively.

IMPORTANCE: They allow the comparison of the performances of various algorithms.

SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
SUBJECT: Algorithms
Comparison of Functions:

SUBJECT: Algorithms
Comparison of Functions:

SUBJECT: Algorithms
Comparison of Functions:

SUBJECT: Algorithms
Comparison of Functions:

SUBJECT: Algorithms
Comparison of Functions:

SUBJECT: Algorithms
1. Consider the following functions from positives integers to real numbers

10, √n, n, log2n, 100/n.

The CORRECT arrangement of the above functions in increasing order of


asymptotic complexity is:

(A) log2n, 100/n, 10, √n, n


(B) 100/n, 10, log2n, √n, n
(C) 10, 100/n ,√n, log2n, n
(D) 100/n, log2n, 10 ,√n, n

SUBJECT: Algorithms
2. Let f(n) = n and g(n) = n(1+sin n), where n is a positive integer. Which of the
following statements is/are correct?
I. f(n) = O(g(n))
II. f(n) = Ω(g(n))
(A) Only I
(B) Only II
(C) Both I and II
(D) Neither I nor II

SUBJECT: Algorithms
3.

The equality above remains correct if X is replace by


(A) Only I
(B) Only II
(C) I or III or IV but not II
(D) II or III or IV but not I

SUBJECT: Algorithms
4. Let w(n) and A(n) denote respectively, the worst case and average case running
time of an algorithm executed on an input of size n. which of the following is
ALWAYS TRUE?

(A) A(n) = Omega(W(n))


(B) A(n) = Theta(W(n))
(C) A(n) = O(W(n))
(D) A(n) = o(W(n))

SUBJECT: Algorithms
5. Consider the following functions:

f(n) = 2^n
g(n) = n!
h(n) = n^logn
Which of the following statements about the asymptotic behaviour of f(n), g(n), and
h(n) is true?

(A) f(n) = O(g(n)); g(n) = O(h(n))


(B) f(n) = Omega(g(n)); g(n) = O(h(n))
(C) g(n) = O(f(n)); h(n) = O(f(n))
(D) h(n) = O(f(n)); g(n) = Omega(f(n))

SUBJECT: Algorithms
6. Arrange the following functions in increasing asymptotic order:

A. n1/3
B. en
C. n7/4
D. n log9n
E. 1.0000001n

(A) A, D, C, E, B
(B) D, A, C, E, B
(C) A, C, D, E, B
(D) A, C, D, B, E

SUBJECT: Algorithms
7. Let f(n), g(n) and h(n) be functions defined for positive inter such that
f(n) = O(g(n)), g(n) ≠ O(f(n)), g(n) = O(h(n)), and h(n) = O(g(n)).

Which one of the following statements is FALSE?

(A) f(n) + g(n) = O(h(n)) + h(n))


(B) f(n) = O(h(n))
(C) fh(n) ≠ O(f(n))
(D) f(n)h(n) ≠ O(g(n)h(n))

SUBJECT: Algorithms
8. Consider the following three claims
1. (n + k)m = Θ(nm), where k and m are constants
2. 2n + 1 = O(2n)
3. 22n + 1 = O(2n)

Which of these claims are correct ?

(A) 1 and 2
(B) 1 and 3
(C) 2 and 3
(D) 1, 2, and 3

SUBJECT: Algorithms
9. Let f(n) = n2Logn and g(n) = n (logn)10 be two positive functions of n. Which of
the following statements is correct?
(A) f(n) = O(g(n)) and g(n) != O(f(n))
(B) f(n) != O(g(n)) and g(n) = O(f(n))
(C) f(n) = O(g(n)) but g(n) = O(f(n))
(D) f(n) != O(g(n)) but g(n) != O(f(n))

SUBJECT: Algorithms
Glimpse of Next Session:
➢ Recurrence Relation
➢ Solving Recurrence Relation
Using Substitution Method

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