Complexity Theory  Complexity theory is a problem can be solved? Given: ◦ Limited resources: processor time and memory space.

Slides:



Advertisements
Similar presentations
Growth-rate Functions
Advertisements

CSE115/ENGR160 Discrete Mathematics 03/01/12
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
HST 952 Computing for Biomedical Scientists Lecture 10.
Chapter 9: Searching, Sorting, and Algorithm Analysis
Analysys & Complexity of Algorithms Big Oh Notation.
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
Asymptotic Growth Rate
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
Data Structures Performance Analysis.
Cmpt-225 Algorithm Efficiency.
CS 206 Introduction to Computer Science II 09 / 05 / 2008 Instructor: Michael Eckmann.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Lecture 3 Aug 31, 2011 Goals: Chapter 2 (algorithm analysis) Examples: Selection sorting rules for algorithm analysis discussion of lab – permutation generation.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Algorithm Efficiency and Sorting Bina Ramamurthy CSE116A,B.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Lecture 3 Feb 7, 2011 Goals: Chapter 2 (algorithm analysis) Examples: Selection sorting rules for algorithm analysis Image representation Image processing.
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
Algorithm Analysis (Big O)
COMP s1 Computing 2 Complexity
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Discrete Structures Lecture 11: Algorithms Miss, Yanyan,Ji United International College Thanks to Professor Michael Hvidsten.
{ CS203 Lecture 7 John Hurley Cal State LA. 2 Execution Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
Analysis of Algorithms
Algorithm Evaluation. What’s an algorithm? a clearly specified set of simple instructions to be followed to solve a problem a way of doing something What.
Analysis of Algorithm Efficiency Dr. Yingwu Zhu p5-11, p16-29, p43-53, p93-96.
© 2011 Pearson Addison-Wesley. All rights reserved 10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Analysis of Algorithms CSCI Previous Evaluations of Programs Correctness – does the algorithm do what it is supposed to do? Generality – does it.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use by MSU Dept. of Computer Science.
Data Structure Introduction.
New Mexico Computer Science For All Algorithm Analysis Maureen Psaila-Dombrowski.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
3.3 Complexity of Algorithms
1 5. Abstract Data Structures & Algorithms 5.6 Algorithm Evaluation.
The Fundamentals. Algorithms What is an algorithm? An algorithm is “a finite set of precise instructions for performing a computation or for solving.
Algorithm Analysis (Big O)
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
E.G.M. PetrakisAlgorithm Analysis1  Algorithms that are equally correct can vary in their utilization of computational resources  time and memory  a.
Searching Topics Sequential Search Binary Search.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
LECTURE 2 : fundamentals of analysis of algorithm efficiency Introduction to design and analysis algorithm 1.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Lecture 3COMPSCI.220.S1.T Running Time: Estimation Rules Running time is proportional to the most significant term in T(n) Once a problem size.
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Introduction to Analysis of Algorithms
Analysis of Algorithms
GC 211:Data Structures Week 2: Algorithm Analysis Tools
GC 211:Data Structures Algorithm Analysis Tools
Big-O notation.
DATA STRUCTURES Introduction: Basic Concepts and Notations
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
GC 211:Data Structures Algorithm Analysis Tools
CS 201 Fundamental Structures of Computer Science
Analyzing an Algorithm Computing the Order of Magnitude Big O Notation
Algorithmic Complexity
GC 211:Data Structures Algorithm Analysis Tools
Time Complexity Lecture 14 Sec 10.4 Thu, Feb 22, 2007.
Revision of C++.
Time Complexity Lecture 15 Mon, Feb 27, 2006.
Presentation transcript:

Complexity Theory

 Complexity theory is a problem can be solved? Given: ◦ Limited resources: processor time and memory space

Algorithm

 Definition: An algorithm is a finite step-by-step list of well- defined instructions for solving a particular problem.  Algorithm complexity: is a key task in comparing the efficiency of algorithms.  Two factors are considered: ◦ 1- the (running) timeTime Complexity ◦ 2- the space (usage)Space Complexity

 Time Complexity: estimates the running time of the algorithm. ◦ Measured by the number of key step of the basic steps used by the algorithm.  Basic Steps are: ◦ Arithmetic operations (+, -, *, /) ◦ Comparison operations (>, >=, <, <=, ==) ◦ Reading from a memory, file ◦ Writing to memory, file, (cin, fin)

 Key step: The most costly step of the algorithm ◦ Takes most of the running time ◦ Other steps is much less or at most proportional to the time of the key step.

 In worse-case analysis: ◦ We find the maximum value of the number of the key steps.  In Average-case analysis: ◦ We find the average value of the number of the key steps.

 Let f (n ) the complexity of an algorithm, i.e., ◦ # key operations ◦ For an instance of size n  A computer processor has a speed of 1 MIP ◦ Million Instructions Per (MIP) second

 Big Oh O() Notation is used ◦ To estimate the growth rate of f : N R + ◦ f O(g) ◦ There exist two positive integer k, n 0 :  f(n) ≤ k*g(n), for all n ≥ n 0  f grows not fast than g  f belongs to the complexity class O(g)

f(n) = 3 n+2= O(n) as 3 n +2 ≤ 4 n for all n ≥ 2. f(n) =100 n+6=O(n) as 100 n+6 ≤ 101 n for all n ≥ 6. f(n) =1000 n n - 6 = Ο(n 2 ) as 1000 n n - 6 ≤ 1001 n 2 for all n ≥ 100. f(n) = 6 2 n + n 2 = Ο (2 n ) as 6 2 n + n 2 ≤ 7 * 2 n for all n ≥ 4.

 Find the class complexity of the following functions  1. f(n) = n n 2 - 8n + 6  2. f(n) = (6n 7 +4) / (n 2 +1)  3. f(n) = 2 n + 3n n 4

 Common complexity classes  O(1)< O(log n) < O(n)< O(n log n)< O(n 2 )<O(n 3 )< O(2 n )< O(10 n )  O(n log n) is better than O(n 2 )  O(n) is better than O(n log n)

 Dropping Coefficient ◦ f(n) = k * n c f O(n c ) ◦ f(n) = 10 n 4 f O(n 4 )  Dominant Term ◦ f(n) = n c +n c-1 +…+ n 2 +n+1 f O(n c ) ◦ f(n) = (n 8 + 1) / (n 3 + 2n 2 – 1) f O(n 5 )

Introduction to Algorithms

What is Algorithm ??

 An algorithm : is a finite step-by-step list of well-defined instructions for solving a particular problem.  Algorithm complexity is a key task in comparing the efficiency of algorithms.  Two factors are considered: ◦ 1- the (running) timeTime Complexity ◦ 2- the space (usage)Space Complexity

 Sorting Algorithms ◦ Bubble Sort ◦ Insertion Sort ◦ And many other algorithms (Quick Sort, Selection Sort, …. )  Searching Algorithms ◦ Linear search (sequential search) ◦ Binary search ◦ And many other algorithms (BFS, DFS, … )  And There are many and many algorithms used in this fields and other fields.

Sorting Algorithms Bubble sort

Insertion Sort