CS8451 DAA Unit I Notes
CS8451 DAA Unit I Notes
CS8451 DAA Unit I Notes
• Brute force
• Dynamic programming
• Backtracking
• Branch and bound
• list
– array
– linked list
– string
• stack
• queue
• priority queue
• graph
• tree
• set and dictionary
7) What are the sequence of steps in designing and analyzing the algorithm?
input
size
Orders of Growth
The algorithm runs the longest among all possible inputs of size n.
Best case
Efficiency (# of times the basic operation will be executed) for the best
case input of size n.
The algorithm runs the fastest among all possible inputs of size n.
Average case:
Efficiency (#of times the basic operation will be executed) for a
typical/random input of size n.
NOT the average of worst and best case
How to find the average case efficiency?
13) What are asymptotic notations? Explain in detail.
Asymptotic Growth Rate
Three notations used to compare orders of growth of an algorithm’s basic
operation count
O(g(n)): class of functions f(n) that grow no faster than g(n)
Ω(g(n)): class of functions f(n) that grow at least as fast as g(n)
Θ (g(n)): class of functions f(n) that grow at same rate as g(n)
O-notation
Formal definition
A function t(n) is said to be in O(g(n)), denoted t(n) O(g(n)), if t(n) is
bounded above by some constant multiple of g(n) for all large n, i.e., if
there exist some positive constant c and some nonnegative integer n0 such
that
t(n) cg(n) for all n n0
6
-notation
Formal definition
A function t(n) is said to be in (g(n)), denoted t(n) (g(n)), if t(n) is
bounded below by some constant multiple of g(n) for all large n, i.e., if
there exist some positive constant c and some nonnegative integer n0 such
that
t(n) cg(n) for all n n0
-notation
Formal definition
A function t(n) is said to be in (g(n)), denoted t(n) (g(n)), if t(n) is
bounded both above and below by some positive constant multiples of
g(n) for all large n, i.e., if there exist some positive constant c1 and c2 and
some nonnegative integer n0 such that
c2 g(n) t(n) c1 g(n) for all n n0
7
1 constant
log n logarithmic
n linear
n log n n log n
n3 cubic
2n exponential
n! factorial
Visiting a vertex or
Typical graph problem #vertices and/or edges
traversing an edge
16) Write an algorithm for counting binary digits for a decimal number.