Sei sulla pagina 1di 37
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis of Algorithm Efficiency

and Analysis of Algorithm Analysis of Algorithm Efficiency c Definition of Analysis of Algorithm c Time

c

Definition of Analysis of Algorithm

c

Time and Space Efficiency

c

Asymptotic Order of Growth

c

Algorithm Case Efficiencies

c

Asymptotic Notations

c

Basic Efficiency Classes

c

Mathematical Analysis of Recursive Algorithms

c

Mathematical Analysis of Non-Recursive Algorithms

c

Empirical Analysis of Algorithm

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis Framework
Analysis Framework

c

Analysis of algorithm

q used in a narrower technical sense to mean an investigation of algorithms efficiency with respect to the two resources running time and memory space

c

main considerations:

q

simplicity, generality and efficiency of algorithm

q

speed and memory of computer nowadays

of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
of algorithm q speed and memory of computer nowadays Analysis of Algorithm efficiency * Property of
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis Framework
Analysis Framework

c

Space efficiency

q

amount of memory required by an algorithm to run the application

c

Time efficiency

q

indicates how fast an algorithm is processed in the machine

c

Measuring an Input’s Size

q

examine an algorithm’s efficiency as a function of some parameter n indicating the algorithm’s input size

c

Techniques in Measuring Running Time

q

Using standard unit of time measurement

q

Counting the number of times each algorithm’s operations is executed

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis Framework
Analysis Framework

c Disadvantages of using techniques in analysis of algorithm:

q

Dependence of the computer’s speed

q

Dependence on the quality of the program implementing the computer

q

Dependence on the compiler used in generating the machine code

q

Difficulty of clocking the actual running time of the program

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis Framework
Analysis Framework

cOrder of Growth

q how do time or space requirements grow as the problem size increases

or space requirements grow as the problem size increases Approximate value of different important functions for

Approximate value of different important functions for algorithm analysis

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analysis Framework
Analysis Framework

c

Worst-case efficiency

c

Best-case efficiency

c

Average-case efficiency

c

Amortized efficiency

c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
c Average-case efficiency c Amortized efficiency Analysis of Algorithm efficiency * Property of STI Page 6
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c

Asymptotic complexity

q way of expressing the main component of the cost of an algorithm using idealized units of computational work

of an algorithm using idealized units of computational work c Notation used in comparing and ranking
of an algorithm using idealized units of computational work c Notation used in comparing and ranking

c

Notation used in comparing and ranking the order of growth

q

Big-0h Notation (0)

q

Big-0mega Notation (? )

q

Big-Theta Notation (T)

q Big-0mega Notation (? ) q Big-Theta Notation (T) Analysis of Algorithm efficiency * Property of
q Big-0mega Notation (? ) q Big-Theta Notation (T) Analysis of Algorithm efficiency * Property of
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c

Big-0 Notation (0)

q

introduced in 1854 by Paul Bachmann

q

most commonly used notation for specifying asymptotic complexity

c

Big-O means “on the order of”

q

formal method of expressing the upper bound of an algorithm's running time.

c

Write f(n) = O(g(n)) if there exist constants

c

> 0, n0 > 0 such that 0 = f(n) = cg(n) for all

n

= n 0

0 such that 0 = f(n) = cg(n) for all n = n 0 Analysis of
0 such that 0 = f(n) = cg(n) for all n = n 0 Analysis of
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Practical Example:

q

O (n)

 

printing a list of n items to the screen, looking at each item once

q

O (log n)

taking a list of items, cutting it in half repeatedly until there's only one item left

q

O (n2)

• taking a list of n items, and comparing every item to every other item

of n items, and comparing every item to every other item Analysis of Algorithm efficiency *
of n items, and comparing every item to every other item Analysis of Algorithm efficiency *
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Theory Example:

q Given:

f(n) = 2n + 8, and g(n) = n2

c Theory Example: q Given: f(n) = 2n + 8, and g(n) = n2 q Find
c Theory Example: q Given: f(n) = 2n + 8, and g(n) = n2 q Find

q

Find c, so that 2n + 8 <= n 2

+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
+ 8, and g(n) = n2 q Find c , so that 2n + 8 <=
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c The Big-O notation can be derived from f(n) using the following steps:

q

set the coefficient of the term to 1

q

keep the largest term in the function and discard the others

q

terms are ranked from lowest to highest

the others q terms are ranked from lowest to highest log 2 n, n, nlog 2
log 2 n, n, nlog 2 n, n 2, n 3 n k 2 n
log 2 n, n, nlog 2 n, n 2, n 3
n k 2 n n!
lowest to highest log 2 n, n, nlog 2 n, n 2, n 3 n k
lowest to highest log 2 n, n, nlog 2 n, n 2, n 3 n k
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Example#1:

and Analysis of Algorithm Asymptotic Notation c Example#1: q remove all coefficients • n2 + n
and Analysis of Algorithm Asymptotic Notation c Example#1: q remove all coefficients • n2 + n
and Analysis of Algorithm Asymptotic Notation c Example#1: q remove all coefficients • n2 + n

q

remove all coefficients

n2 + n

q

remove the smaller factors

n2

q

Big-O notation:

o(f(n) = o(n2)

• n2 q Big-O notation: • o(f(n) = o(n2) Analysis of Algorithm efficiency * Property of
• n2 q Big-O notation: • o(f(n) = o(n2) Analysis of Algorithm efficiency * Property of
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Example#2:

f(n) = a j n k + a j-1 n k-1 + …+a 2 n 2 +a 1 n+a 0

q

remove all coefficients

f(n) = n k +n k-1 + …+n 2 +n+1

q

the order of a polynomial expression is:

o(f(n) = o(n k )

of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
of a polynomial expression is: • o(f(n) = o(n k ) Analysis of Algorithm efficiency *
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Big-0 Measures of Efficiency

Asymptotic Notation c Big-0 Measures of Efficiency Analysis of Algorithm efficiency * Property of STI Page
Asymptotic Notation c Big-0 Measures of Efficiency Analysis of Algorithm efficiency * Property of STI Page
Asymptotic Notation c Big-0 Measures of Efficiency Analysis of Algorithm efficiency * Property of STI Page
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Big-0mega Notation (? )

q

t(n) ? (g(n))

q

Sample formal proof where n 3 ? (n 2 )

B 3 = n 2 for all n = 0

q

select c =1 and n 0 =0

= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
= n 2 for all n = 0 q select c =1 and n 0 =0
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Big-Theta Notation (T)

q

applied in tight bound

q

function t(n) is said to be in T(g(n)), denoted t(n) T(g(n))

• if t(n) is bounded both above and below by some positive constant multiples of g(n) for all large n

• If there exist some positive constant c1 and c2 and some nonnegative integer n 0 such that:

c 2 g (n) = t(n) = c 1 g(n) for all n = n 0

that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
that: c 2 g (n) = t(n) = c 1 g(n) for all n = n
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c For example, let us prove that right inequality (the upper bound):

let us prove that right inequality (the upper bound): q First, we prove the right inequality
let us prove that right inequality (the upper bound): q First, we prove the right inequality

q First, we prove the right inequality (the upper bounds)

q First, we prove the right inequality (the upper bounds) Analysis of Algorithm efficiency * Property
q First, we prove the right inequality (the upper bounds) Analysis of Algorithm efficiency * Property
q First, we prove the right inequality (the upper bounds) Analysis of Algorithm efficiency * Property
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Asymptotic Notation
Asymptotic Notation

c Continuation:

q Second, we prove the left inequality (the lower bounds).

q Second, we prove the left inequality (the lower bounds). q Hence: Analysis of Algorithm efficiency
q Second, we prove the left inequality (the lower bounds). q Hence: Analysis of Algorithm efficiency

q Hence:

we prove the left inequality (the lower bounds). q Hence: Analysis of Algorithm efficiency * Property
we prove the left inequality (the lower bounds). q Hence: Analysis of Algorithm efficiency * Property
we prove the left inequality (the lower bounds). q Hence: Analysis of Algorithm efficiency * Property
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Algorithm’s efficiency

q

a function of the number of elements to be processed

q

general format:

f (n) = efficiency
f (n) = efficiency
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
to be processed q general format: f (n) = efficiency Analysis of Algorithm efficiency * Property
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Linear Loops

q Example: • identify how many times the body of the loop is repeated: 1
q
Example:
identify how many times the body of the loop is
repeated:
1 x = 0
2 loop (x >= 1000)
1 application code
2 x = x plus 1
3 end loop
q
the number of iterations is directly
proportional to the loop factor
q
the higher the factor, the higher the number of
loops
q
efficiency is directly proportional to the
number of iterations
f (n) = n
f (n) = n
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Linear Loops

q Example: 1 x = 0 2 loop (x >= 1000) 1 application code 2
q
Example:
1 x = 0
2 loop (x >= 1000)
1 application code
2 x = x plus 2
3 end loop
q
the number of iterations is half the loop factor
q
Efficiency is proportional to half the factor
f (n) = n/2
f (n) = n/2
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Logarithmic Loops

q

a loop in which the controlling variable is multiplied or divided in each loop

q

determine how many times the body of the loops is repeated:

1 x = 1 2 loop (x >= 1000) 1 application code 2 x =
1 x = 1
2 loop (x >= 1000)
1 application code
2 x = x multiply 2
3 end loop
1 x = 1000 2 loop (x >= 1) 1 application code 2 x =
1 x = 1000
2 loop (x >= 1)
1 application code
2 x = x divide 2
3 end loop
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Logarithmic Loops

of Algorithm Basic Efficiency Classes c Logarithmic Loops Analysis of Multiplication and Division Loops f (n)

Analysis of Multiplication and Division Loops

f (n) = [log 2 n]
f (n) = [log 2 n]
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Nested Loop

q loop within a loop

Iterations = outer loop iterations x inner loop iterations
Iterations = outer loop iterations x
inner loop iterations
Iterations = outer loop iterations x inner loop iterations q includes Linear Logarithmic, Dependent Quadratic, and

q includes Linear Logarithmic, Dependent Quadratic, and Quadratic

Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Linear Logarithmic, Dependent Quadratic, and Quadratic Analysis of Algorithm efficiency * Property of STI Page
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Linear logarithmic:

Inner Outer 1 x = 1 loop loop 2 loop (x<=10) 1 k = 1
Inner
Outer
1 x = 1
loop
loop
2 loop (x<=10)
1 k = 1
2 loop(k <=10)
1 application code
2 k = k multiply 2
3 end loop
3 end loop

c number of iteration in the inner loop is [log 2 10]

c number of iteration in the inner loop is [log 2 10] 10 x [log 2
c number of iteration in the inner loop is [log 2 10] 10 x [log 2
10 x [log 2 10]
10 x [log 2 10]
f(n) = [nlog 2 n]
f(n) = [nlog 2 n]
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes
c Dependent quadratic : 1 x = 10 2 loop (x <= 10) 1 k
c
Dependent quadratic :
1 x = 10
2 loop (x <= 10)
1 k = 1
2 loop (k <= x)
1
application code
k = k +1
3 end loop
2
3 end loop
c
inner loop depends on the outer loop for one of its
factors
c
the number of iteration is 55
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c average is 5.5

of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
of Algorithm Basic Efficiency Classes c average is 5.5 Analysis of Algorithm efficiency * Property of
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Basic Efficiency Classes
Basic Efficiency Classes

c Quadratic:

1 x = 10 2 loop ( x <= 10) 1 k = 1 2
1
x = 10
2 loop ( x <= 10)
1
k = 1
2 loop ( k <= 10)
1
2
application code
k = k + 1
3
end loop
4
x = x + 1
3
end loop
code k = k + 1 3 end loop 4 x = x + 1 3
f(n) = n 2
f(n) = n 2
Design and Analysis of Algorithm

Design and Analysis of Algorithm

SEATWORK
SEATWORK

c Algorithm efficiency application: State whether the statement below is True or False. Defend your answer.

1. 20n 2 + 2n + 5 = O(n 2 )

. Defend your answer. 1. 20n 2 + 2n + 5 = O(n 2 ) 2.
. Defend your answer. 1. 20n 2 + 2n + 5 = O(n 2 ) 2.
. Defend your answer. 1. 20n 2 + 2n + 5 = O(n 2 ) 2.

2. 100n + 5 = O(n 2 )

20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
20n 2 + 2n + 5 = O(n 2 ) 2. 100n + 5 = O(n
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Mathematical Analysis of Recursive Algorithms

of Algorithm Mathematical Analysis of Recursive Algorithms c General plan of analyzing Time Efficiency of recursive

c General plan of analyzing Time Efficiency of recursive algorithm

1. Decide on a parameter (or parameters) indicating an input’s size.

2. Identify the algorithm’s basic operation.

3. Check whether number of times the basic operation is executed can vary on different inputs of the same size

4. Set up recurrence relation, with appropriate initial condition, for the number of times the basic operation is executed.

5. Solve the recurrence or at least ascertain the order of growth of its solution.

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Mathematical Analysis of Recursive Algorithms

of Algorithm Mathematical Analysis of Recursive Algorithms c Compute the factorial function f(n) = n! for

c

Compute the factorial function f(n) = n! for an arbitrary nonnegative integer n. Since:

n! = 1 , ….(n-1) . n = (n-1)! . n for n =1

c

With 0 != 1 by definition, we can compute F(n) = F(n-1) . n with the following recursive algorithm.

1 if n = 0 return 1 2 else 3 return F(n-1) * n
1 if
n = 0 return 1
2 else
3 return F(n-1) * n
algorithm. 1 if n = 0 return 1 2 else 3 return F(n-1) * n c
algorithm. 1 if n = 0 return 1 2 else 3 return F(n-1) * n c

c

F(n) = F(n-1) . nfor every n > 0

c

M(n) = M (n-1) + 1for every n > 0

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Mathematical Analysis of Non-Recursive Algorithms

Algorithm Mathematical Analysis of Non-Recursive Algorithms c General Plan for Analyze Time Efficiency 1. Decide on

c General Plan for Analyze Time Efficiency

1. Decide on a parameter (or parameters) indicating an input’s size.

2. Identify the algorithms basic operation.

3. Check whether the number of times the basic operation is executed depends only on the size of an input.

4. Set up a sum expressing the number of times the algorithm’s basic operation is executed.

5. Using standard formulas and rules of sum manipulation, either find a close-form formula for the count, or the very least, establish its order of growth.

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Mathematical Analysis of Non-Recursive Algorithms

Algorithm Mathematical Analysis of Non-Recursive Algorithms c Example: maxValue = A[0] loop index = n if
c Example: maxValue = A[0] loop index = n if A[index ] > maxValue return
c
Example:
maxValue = A[0]
loop index = n
if A[index ] > maxValue
return maxValue
c
find a formula in expressing C as a function
of size n
c find a formula in expressing C as a function of size n Analysis of Algorithm
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Empirical Analysis of Algorithm

and Analysis of Algorithm Empirical Analysis of Algorithm c Empirical analysis q alternative of the mathematical

c

Empirical analysis

q alternative of the mathematical analysis of algorithms efficiency

c

General Plan for Empirical Analysis of Algorithm Time Efficiency

1. Understand the experiments purpose.

2. Decide on efficiency metric M to be measure and the measurement unit (an operation’s count vs. a time unit).

3. Decide on characteristics of the input sample (its range, size and so on).

4. Prepare a program implementing the algorithm ( or algorithms) for the experimentation.

5. Generate a sample of inputs.

6. Run algorithms on the sample inputs and record the data observed.

7. Analyzed the data obtained.

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Empirical Analysis of Algorithm

and Analysis of Algorithm Empirical Analysis of Algorithm c Limitations of Empirical Analysis q Quality of

c Limitations of Empirical Analysis

q

Quality of implementation

q

Extraneous factors

q

Requires a working program

q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
q Extraneous factors q Requires a working program Analysis of Algorithm efficiency * Property of STI
Design and Analysis of Algorithm

Design and Analysis of Algorithm

SEATWORK
SEATWORK

c Calculate the run-time efficiency of the following pseudocode for program segments.(10 points each)

x = 0

loop( x <= n)

print x

x = x + 1

end loop

x = 0 loop( x <= n) print x x = x + 1 end loop
x = 0 loop( x <= n) print x x = x + 1 end loop

sum = 0; for( i = 0; i < n; i++)

for( j = 0; j < n; j++)

sum++;

Design and Analysis of Algorithm

Design and Analysis of Algorithm

ASSIGNMENT
ASSIGNMENT

c

Research for the following topics:

1. Definition of brute force algorithm technique design technique

2. Applications of brute force algorithm design technique

c

Note: The research work should be in a printed copy and compiled in a folder with a title page.

a printed copy and compiled in a folder with a title page. Analysis of Algorithm efficiency
a printed copy and compiled in a folder with a title page. Analysis of Algorithm efficiency