Docsity

Algorithms and Complexity: Basics of Algorithm Analysis, Summaries of Computer Science

Partial preview of the text

Download Algorithms and Complexity: Basics of Algorithm Analysis and more Summaries Computer Science in PDF only on Docsity!

ALGORITHMS

AND

COMPLEXITY

TOPICS

• Basics on Analysis of Algorithms

• Asymptotic Notations

• Analysis Examples

BASICS ON ANALYSIS OF

ALGORITHMS

  • (^) Analysis of Algorithms is a fundamental aspect of

computer science that involves evaluating performance of

algorithms and programs. Efficiency is measured in terms

of time and space.

Why is Analysis of Algorithm important? • (^) So performance is like currency through which we can buy all the above things. Another reason for studying performance is performance == scale.

  • (^) Algorithm analysis is an important part of computational complexity theory, which provides theoretical estimation for the required resources of an algorithm to solve a specific computational problem. Analysis of algorithms is the determination of the amount of time and space resources required to execute it.

BASICS ON ANALYSIS OF

ALGORITHMS

  • (^) Analysis of Algorithms is a fundamental aspect of

computer science that involves evaluating performance of

algorithms and programs. Efficiency is measured in terms

of time and space.

Why is Analysis of Algorithm important? • (^) So performance is like currency through which we can buy all the above things. Another reason for studying performance is performance == scale.

  • (^) Algorithm analysis is an important part of computational complexity theory, which provides theoretical estimation for the required resources of an algorithm to solve a specific computational problem. Analysis of algorithms is the determination of the amount of time and space resources required to execute it.

Order of Growth

  • (^) Let f(n) and g(n) be the time taken by two algorithms where n >=

9 and f(n) and g(n) are also greater than equal to 0. A function f(n)

is said to be growing faster than g(n) if g(n)/f(n) for n tends to

infinity is 0 (or f(n)/g(n) for n tends to infinity is infinity).

Example 1: f(n) = 1000, g(n) = n + 1 For n > 999, g(n) would always be greater than f(n) because order of growth of g(n) is more than f(n). Example 2 : f( n ) = 4n^2 , g(n) = 2n + 2000 f(n) has higher order of growth as it grows quadratically in terms of input size.

Order of Growth

  • (^) How do we Quickly find order of Growth? When n >= 0, f(n) >= 0 and g(n) >= 0, we can use the below steps. - (^) Ignore the order terms. - (^) Ignore the constants Example 1 : 4n 2 + 3n + 100 After ignoring lower order terms, we get 4n 2 After ignoring constants, we get n^2 Hence order of growth is n 2 Example 1 : 100 n Log n + 3n + 100 Log n + 2 After ignoring lower order terms, we get 100 n Log n After ignoring constants, we get n Log n Hence order of growth is n Log n
  • (^) How do we compare two order of growths? c < Log Log n < Log n < n1/3^ < n1/2^ < n < n Log n < n^2 < n^2 Log n < n^3 < n^4 < 2n^ < nn Here c is a constant