Lecture # 18 - New
Lecture # 18 - New
Lecture # 18 - New
Lecture No 1-4
Decide on : algorithm
design techniques etc.
Design an algorithm
Decide
Decideonon:algorithm
algorithm
design techniques etc.
Design an algorithm
Prove correctness
Decide on : algorithm
design techniques etc.
Design an algorithm
Prove correctness
Decide on : algorithm
design techniques etc.
Design an algorithm
Prove correctness
Lecture No 5
(Analysis Framework.)
Read Chapter 2
Fundamentals of the Analysis
of Algorithm Efficiency
Write a program
implementing the
algorithm
Run the program with
inputs of varying size and
composition
Use a method like
System.currentTimeMillis() to
get an accurate measure
of the actual running
time
Plot the results
Input size
# of times op.
Running time
Execution time for is executed
operation
Total Cost = c1 + c2
sum = sum + i; c5 n
}
Total Cost = An + B (This equation of straight line: y = mx + c)
The time required for this algorithm is directly
proportional to n
Up Shot
Consecutive Statements: Just add the running times
of those consecutive statements.
If/Else: Never more than the running time of the test
plus the larger of running times of S1 and S2.
Loops: The running time of a loop is at most the
running time of the statements inside of that loop times
the number of iterations.
Nested Loops: Running time of a nested loop
containing a statement in the inner most loop is the
running time of statement multiplied by the product of
the sized of all loops.
an algorithm useful?
Let us discuss this with the help of the following
example.
Suppose we have an algorithm that counts the
number of different characters in a file. An
algorithm for that might look like the following:
an algorithm useful?
Let us discuss this with the help of the following
example.
Suppose we have an algorithm that counts the
number of different characters in a file. An
algorithm for that might look like the following:
Multiplication of two
Multiplication of two matrices
numbers
Visiting a vertex or
Typical graph problem
traversing an edge