Algorithm Design and Analysis Liao Minghong School of Computer Science and Technology of HIT July, 2003.

Slides:



Advertisements
Similar presentations
MATH 224 – Discrete Mathematics
Advertisements

Analysis of Algorithms
 The running time of an algorithm as input size approaches infinity is called the asymptotic running time  We study different notations for asymptotic.
Razdan with contribution from others 1 Algorithm Analysis What is the Big ‘O Bout? Anshuman Razdan Div of Computing.
Asymptotic Notation (O, Ω,  ) s Describes the behavior of the time or space complexity for large instance characteristics s Common asymptotic functions.
Chapter 1 – Basic Concepts
Chapter 3 Growth of Functions
CSC401 – Analysis of Algorithms Lecture Notes 1 Introduction
1 ICS 353 Design and Analysis of Algorithms Spring Semester (062) King Fahd University of Petroleum & Minerals Information & Computer Science.
Asymptotic Growth Rate
1 Amortized Analysis Consider an algorithm in which an operation is executed repeatedly with the property that its running time fluctuates throughout the.
Cutler/HeadGrowth of Functions 1 Asymptotic Growth Rate.
CSE 830: Design and Theory of Algorithms Dr. Eric Torng.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 2 Elements of complexity analysis Performance and efficiency Motivation: analysis.
2 -1 Chapter 2 The Complexity of Algorithms and the Lower Bounds of Problems.
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
CSE 5311 DESIGN AND ANALYSIS OF ALGORITHMS. Definitions of Algorithm A mathematical relation between an observed quantity and a variable used in a step-by-step.
Lecture 2 We have given O(n 3 ), O(n 2 ), O(nlogn) algorithms for the max sub-range problem. This time, a linear time algorithm! The idea is as follows:
Program Performance & Asymptotic Notations CSE, POSTECH.
Week 2 CS 361: Advanced Data Structures and Algorithms
Lecture 2 Computational Complexity
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
Mathematics Review and Asymptotic Notation
1 Computer Algorithms Lecture 3 Asymptotic Notation Some of these slides are courtesy of D. Plaisted, UNC and M. Nicolescu, UNR.
CS 3343: Analysis of Algorithms
Unit III : Introduction To Data Structures and Analysis Of Algorithm 10/8/ Objective : 1.To understand primitive storage structures and types 2.To.
Design and Analysis of Algorithms - Chapter 21 Analysis of Algorithms b Issues: CorrectnessCorrectness Time efficiencyTime efficiency Space efficiencySpace.
Analysis of Algorithms
2IL50 Data Structures Fall 2015 Lecture 2: Analysis of Algorithms.
Analysis of Algorithms These slides are a modified version of the slides used by Prof. Eltabakh in his offering of CS2223 in D term 2013.
CMPT 438 Algorithms. Why Study Algorithms? Necessary in any computer programming problem ▫Improve algorithm efficiency: run faster, process more data,
1 Introduction to Data Structures. 2 Course Name : Data Structure (CSI 221) Course Teacher : Md. Zakir Hossain Lecturer, Dept. of Computer Science Stamford.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
MS 101: Algorithms Instructor Neelima Gupta
Fundamentals of Algorithms MCS - 2 Lecture # 8. Growth of Functions.
Chapter 10 Algorithm Analysis.  Introduction  Generalizing Running Time  Doing a Timing Analysis  Big-Oh Notation  Analyzing Some Simple Programs.
Analysis of Algorithms1 O-notation (upper bound) Asymptotic running times of algorithms are usually defined by functions whose domain are N={0, 1, 2, …}
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Asymptotic Growth Rates  Themes  Analyzing the cost of programs  Ignoring constants and Big-Oh  Recurrence Relations & Sums  Divide and Conquer 
Time Complexity of Algorithms (Asymptotic Notations)
Lecture 2 Analysis of Algorithms How to estimate time complexity? Analysis of algorithms Techniques based on Recursions ACKNOWLEDGEMENTS: Some contents.
Asymptotic Notations By Er. Devdutt Baresary. Introduction In mathematics, computer science, and related fields, big O notation describes the limiting.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
2IS80 Fundamentals of Informatics Fall 2015 Lecture 5: Algorithms.
Spring 2015 Lecture 2: Analysis of Algorithms
David Meredith Growth of Functions David Meredith
E.G.M. PetrakisAlgorithm Analysis1  Algorithms that are equally correct can vary in their utilization of computational resources  time and memory  a.
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
Data Structures and Algorithm Analysis Algorithm Analysis and Sorting
2IL50 Data Structures Spring 2016 Lecture 2: Analysis of Algorithms.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Data Structures & Algorithm CS-102 Lecture 12 Asymptotic Analysis Lecturer: Syeda Nazia Ashraf 1.
Introduction to Data Structures
Basic Concepts in Algorithmic Analysis
Complexity analysis.
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
DATA STRUCTURES Introduction: Basic Concepts and Notations
Chapter 2 Fundamentals of the Analysis of Algorithm Efficiency
Asymptotic Notations Algorithms Lecture 9.
Objective of This Course
Asymptotic Growth Rate
Chapter 2.
ICS 353: Design and Analysis of Algorithms
Discrete Mathematics 7th edition, 2009
Presentation transcript:

Algorithm Design and Analysis Liao Minghong School of Computer Science and Technology of HIT July, 2003

Course Description Course Name: Algorithm Design and Analysis Course Type: Selected Undergraduate Course Teaching hours: 30 Teaching materials: Algorithms Design Techniques and Analysis, M. H. Alsuwaiyel, Publishing House of Electronics Industry, 2003

Reference Materials Thomas H.Cormen, et al., Introduction to Algorithms, Higher Education Press, The MIT Press, 2002 王晓东,算法设计与分析,清华大学出 版社,

Course Contents Part 1: Basic Concepts and Introduction to Algorithms Part 2: Techniques Based on Recursion Part 3: First-Cut Techniques Part 4: Complexity of Problems Part 5: Coping with Hardness

Course Contents_Part 1 Chapter 1:Basic Concepts in Algorithmic Analysis Chapter 2: Mathematical Preliminaries Chapter 3: Data Structure Chapter 4: Heaps and the Disjoint Sets Structures

Course Contents_Part 2 Chapter 5: Introduction Chapter 6: Divide and Conquer Chapter 7: Dynamic Programming

Course Contents_Part 3 Chapter 8: The Greedy Approach Chapter 9: Graph Traversal

Course Contents_Part 4 Chapter 10: NP-Complete Problems Chapter 11: Introduction to computational complexity Chapter 12: Lower Bounds

Course Contents_Part 5 Chapter 13: Backtracking Chapter 14: Randomized Algorithms Chapter 15: Approximation Algorithms

Chapter 1: Basic Concepts in Algorithmic Analysis Basic Concepts of Algorithms Time Complexity How to Estimate the running Time of an Algorithm Worst case and average case analysis Amortized analysis

1.1 Basic Concepts of Algorithms Architecture of Computational Science

Process of solving problem problemcomputabilitycomplexityAlgorithmsprogrammingSoftware system Architecture Computability theory Computable & non computable Computational model Equivalence of model Complexity theory Worst case Best case Average case P =? NP Algorithms design & analysis Design algorithms Analysis technique Optimal algorithms C language Java language …

1.1 Basic Concepts of Algorithms Algorithm: is a procedure that consists of a finite set of instructions which, given an input from some set of possible inputs,enables us to obtain an output if such an output exists or else obtain nothing at all if there is no output for that particular input through a systematic execution of the instructions.

1.1 Basic Concepts of Algorithms Characteristics of Algorithms –Corrective –Concrete steps –Determinative –Limited –Halted

1.1 Basic Concepts of Algorithms_some algorithms Linear Search Binary Search Selection sort Insertion sort Merge Sort Quick sort Etc.

1.2 Time Complexity Order of growth The O-notation The Ω-notation The Θ-notation The o-notation

1.2 Time Complexity _Order of growth Definition1.1 elementary operation We denote by an “elementary operation” any computational step whose cost is always upperbounded by a constant amount of time regardless of the input data or the algorithm used.

1.2 Time Complexity _Order of growth Fig. 1.5 growth of some typical functions that represent running times

Definition 1.2 The O-notation Let f(n) and g(n) be the functions from the set of natural numbers to the set of nonnegative real numbers. f(n) is said to be O(g(n)) if there exists a natural number n 0 and a constant c>0 such that n>=n 0, f(n)<=cg(n). Consequently, if lim f(n)/g(n) exists, then lim, implies f(n)=O(g(n))

Definition 1.3 The Ω-notation Let f(n) and g(n) be two functions from the set of natural numbers to the set of nonnegative real numbers. f(n) is said to be Ω(g(n)) if there exists a natural number n 0 and a constant c>0 such that n>=n 0, f(n)>=cg(n). Consequently, if lim f(n)/g(n) exists, then lim, implies f(n)= Ω(g(n))

Definition 1.4 The Θ-notation Let f(n) and g(n) be two functions from the set of natural numbers to the set of nonnegative real numbers. f(n) is said to be Θ(g(n)) if there exists a natural number n 0 and two positive constants c1 and c2 such that n>=n 0, c1g(n)<=f(n)<=c2g(n). Consequently, if lim f(n)/g(n) exists, then Lim, implies f(n)= Θ(g(n)) Where c is a constant strictly greater than 0.

Definition 1.5 The o-notation Let f(n) and g(n) be the functions from the set of natural numbers to the set of nonnegative real numbers. f(n) is said to be o(g(n)) if for every constant c>0 there exists a positive integer n 0 such that f(n) =n 0. Consequently, if lim f(n)/g(n) exists, then Lim, implies f(n)=o(g(n))

Definition 1.6 Complexity Classes Let R be the relation on the set of complexity functions defined by f R g if and only if f(n)= Θ(g(n)). It is easy to see that R is reflexive, symmetric and transitive, i.e., an equivalence relation. The equivalence classes induced by this relation are called complexity classes. e.g. all polynomials of degree 2 belong to the same complexity class n 2.

Definition 1.7 Space Complexity We define the space used by an algorithm to be the number of memory cells needed to carry out the computational steps required to solve an instance of the problem excluding the space allocated to hold the input. All definition of order of growth and asymptotic bounds pertaining to time complexity carry over to space complexity. Let T(n) and S(n) denote, respectively, the time and space complexity of an algorithm, then S(n)=O(T(n))

1.3 Worst case analysis In worst case analysis of time complexity we select the maximum cost among all possible inputs of size n. Under the worst case assumption, the notions of upper and lower bounds in many algorithms coincide and, consequently, we may say that an algorithm runs in time Θ (f(n)) in the worst case. But the upper and lower bounds are not always coincide.

1.4 Average case analysis The running time is taken to be the average time over all inputs of size n. It is necessary to know the probabilities of all input occurrences. The analysis is in many cases complex and lengthy

1.5 Amortized analysis Unable to express the time complexity in terms of the Θ-notation,we will be content with the O- notation, but the algorithm may be much faster than our estimate even in the worst case. If the operation takes a large amount of time occasionally and runs much faster most of the time, then this is an indication that amortized analysis should be employed.

1.5 Amortized analysis In amortized analysis, we average out the time taken by the operation throughout the execution of the algorithm, and refer to this average as the amortized running time of that operation. Different with average case analysis: –The average is taken over all instances of the same size. –The average need to assume that the probability distribution of the input.

1.5 Amortized analysis Example 1.32 We have a doubly linked list that initially consists of one node which contains the integer 0. We have as input an array A[1..n] of n positive integers that are to be processed in the following way. If the current integer x is odd, then append x to the list. If it is even, then first append x and then remove all odd elements before x in the list. Let us analyze the running time of this algorithm.

The algorithm: for j = 1 to n x=a[j] append x to the list if x is even then while pred(x) is odd delete pred(x) end while end if end for

1.5 Amortized analysis Time complexity analysis: General analysis: O(n 2 ) Amortized analysis: Θ(n) (number of insertions: n, and the number of deletions: 0~n-1, so the total operations: n~2n-1)