Algorithm Efficiency and Sorting

Slides:



Advertisements
Similar presentations
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Advertisements

The Efficiency of Algorithms Chapter 4 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
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.
Chapter 10 Algorithm Efficiency
© 2006 Pearson Addison-Wesley. All rights reserved10-1 Chapter 10 Algorithm Efficiency and Sorting CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck.
© 2006 Pearson Addison-Wesley. All rights reserved6-1 More on Recursion.
Cmpt-225 Algorithm Efficiency.
The Efficiency of Algorithms
The Efficiency of Algorithms Chapter 9 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
The Efficiency of Algorithms
Algorithm Efficiency and Sorting Bina Ramamurthy CSE116A,B.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Pointers Contd.. Causing a Memory Leak int *ptr = new int; *ptr = 8; int *ptr2 = new int; *ptr2 = -5; ptr = ptr2; ptr 8 ptr2 -5 ptr 8 ptr2 -5.
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Cmpt-225 Simulation. Application: Simulation Simulation  A technique for modeling the behavior of both natural and human-made systems  Goal Generate.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
Program Performance & Asymptotic Notations CSE, POSTECH.
Measuring the Efficiency of Algorithms Analysis of algorithms Provides tools for contrasting the efficiency of different methods of solution Time efficiency,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 9: Algorithm Efficiency and Sorting Data Abstraction &
Algorithm Efficiency Chapter 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
© 2011 Pearson Addison-Wesley. All rights reserved 10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Chapter 10 A Algorithm Efficiency. © 2004 Pearson Addison-Wesley. All rights reserved 10 A-2 Determining the Efficiency of Algorithms Analysis of algorithms.
Analysis of Algorithms CSCI Previous Evaluations of Programs Correctness – does the algorithm do what it is supposed to do? Generality – does it.
Algorithm Efficiency and Sorting Data Structure & Algorithm.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Efficiency of Algorithms. Node - data : Object - link : Node + createNode() + getData() + setData() + getLink() + setLink() + addNodeAfter() + removeNodeAfter()
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.
© 2017 Pearson Education, Hoboken, NJ. All rights reserved
Algorithm Analysis 1.
Chapter 10 Algorithm Efficiency
Algorithm Efficiency and Sorting
CS 302 Data Structures Algorithm Efficiency.
Introduction to Analysis of Algorithms
Analysis of Algorithms
Algorithm Efficiency and Sorting
Introduction to Analysis of Algorithms
Analysis of Algorithms
Introduction to Algorithms
Introduction to Analysis of Algorithms
Big-O notation.
Algorithm Analysis and Big Oh Notation
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Chapter 17 Linked Lists.
The Efficiency of Algorithms
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Algorithm Efficiency Chapter 10.
Analysys & Complexity of Algorithms
Algorithm Efficiency and Sorting
Analysis of Algorithms
Algorithm Efficiency: Searching and Sorting Algorithms
Chapter 2.
Algorithm Efficiency Chapter 10
Algorithm Analysis Bina Ramamurthy CSE116A,B.
The Efficiency of Algorithms
Chapter 5 Algorithm Analysis.
Algorithm Efficiency and Sorting
Algorithm Analysis and Big Oh Notation
The Efficiency of Algorithms
Algorithm Efficiency and Sorting
Introduction: Some Representative Problems
Algorithm Efficiency and Sorting
The Efficiency of Algorithms
Chapter 6 Dynamic Programming.
Algorithm Efficiency and Sorting
Chapter 2 Reference Types.
Analysis of Algorithms
Algorithm Efficiency and Sorting
Algorithm Efficiency and Sorting
Presentation transcript:

Algorithm Efficiency and Sorting Chapter 10 Algorithm Efficiency and Sorting © 2011 Pearson Addison-Wesley. All rights reserved

Measuring the Efficiency of Algorithms Analysis of algorithms Provides tools for contrasting the efficiency of different methods of solution A comparison of algorithms Should focus of significant differences in efficiency Should not consider reductions in computing costs due to clever coding tricks © 2011 Pearson Addison-Wesley. All rights reserved

Measuring the Efficiency of Algorithms Three difficulties with comparing programs instead of algorithms How are the algorithms coded? What computer should you use? What data should the programs use? Algorithm analysis should be independent of Specific implementations Computers Data © 2011 Pearson Addison-Wesley. All rights reserved

The Execution Time of Algorithms Counting an algorithm's operations is a way to access its efficiency An algorithm’s execution time is related to the number of operations it requires Examples Traversal of a linked list Nested Loops © 2011 Pearson Addison-Wesley. All rights reserved

Algorithm Growth Rates An algorithm’s time requirements can be measured as a function of the problem size An algorithm’s growth rate Enables the comparison of one algorithm with another Examples Algorithm A requires time proportional to n2 Algorithm B requires time proportional to n Algorithm efficiency is typically a concern for large problems only © 2011 Pearson Addison-Wesley. All rights reserved

Algorithm Growth Rates Figure 10-1 Time requirements as a function of the problem size n © 2011 Pearson Addison-Wesley. All rights reserved

Order-of-Magnitude Analysis and Big O Notation Definition of the order of an algorithm Algorithm A is order f(n) – denoted O(f(n)) – if constants k and n0 exist such that A requires no more than k * f(n) time units to solve a problem of size n ≥ n0 Growth-rate function A mathematical function used to specify an algorithm’s order in terms of the size of the problem Big O notation A notation that uses the capital letter O to specify an algorithm’s order Example: O(f(n)) © 2011 Pearson Addison-Wesley. All rights reserved

Order-of-Magnitude Analysis and Big O Notation Figure 10-3a A comparison of growth-rate functions: a) in tabular form © 2011 Pearson Addison-Wesley. All rights reserved

Order-of-Magnitude Analysis and Big O Notation Figure 10-3b A comparison of growth-rate functions: b) in graphical form © 2011 Pearson Addison-Wesley. All rights reserved

Order-of-Magnitude Analysis and Big O Notation Order of growth of some common functions O(1) < O(log2n) < O(n) < O(n * log2n) < O(n2) < O(n3) < O(2n) Properties of growth-rate functions You can ignore low-order terms You can ignore a multiplicative constant in the high-order term O(f(n)) + O(g(n)) = O(f(n) + g(n)) © 2011 Pearson Addison-Wesley. All rights reserved

Order-of-Magnitude Analysis and Big O Notation Worst-case and average-case analyses An algorithm can require different times to solve different problems of the same size Worst-case analysis A determination of the maximum amount of time that an algorithm requires to solve problems of size n Average-case analysis A determination of the average amount of time that an algorithm requires to solve problems of size n © 2011 Pearson Addison-Wesley. All rights reserved