Algorithm Efficiency Chapter 10

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.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Fall 2006CENG 7071 Algorithm Analysis. Fall 2006CENG 7072 Algorithmic Performance There are two aspects of algorithmic performance: Time Instructions.
Processing Data in External Storage CS Data Structures Mehmet H Gunes Modified from authors’ slides.
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.
Data Structures Data Structures Topic #7. Today’s Agenda How to measure the efficiency of algorithms? Discuss program #3 in detail Review for the midterm.
© 2006 Pearson Addison-Wesley. All rights reserved6-1 More on Recursion.
Cmpt-225 Algorithm Efficiency.
The Efficiency of Algorithms Chapter 9 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Algorithm Efficiency and Sorting
Algorithm Efficiency and Sorting Bina Ramamurthy CSE116A,B.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (1) Asymptotic Complexity 10/28/2008 Yang Song.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
© 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.
Algorithm Analysis (Big O)
Implementations of the ADT Stack Chapter 7 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
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.
Searching Chapter 18 © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank.
Tree Implementations Chapter 16 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
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()
Algorithm Analysis (Big O)
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
The Efficiency of Algorithms Chapter 9 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights.
Chapter 4 Link Based Implementations
Link Based Implementations
© 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.
Sorting Algorithms and their Efficiency
Analysis of Algorithms
Analysis of Algorithms
Introduction to Algorithms
Chapter 16 Tree Implementations
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Chapter 4 Link Based Implementations
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
List Implementations Chapter 9
Algorithm Efficiency Chapter 10.
Algorithm Efficiency and Sorting
Analysis of Algorithms
Sorted Lists and Their Implementations
Algorithm Efficiency: Searching and Sorting Algorithms
Chapter 2.
Algorithm Analysis Bina Ramamurthy CSE116A,B.
Algorithmic Complexity
Algorithm Efficiency and Sorting
The Efficiency of Algorithms
The Efficiency of Algorithms
Algorithm Efficiency and Sorting
Analysis of Algorithms
Algorithm Efficiency and Sorting
CMPT 225 Lecture 6 – Review of Complexity Analysis using the Big O notation + Comparing List ADT class implementations.
Presentation transcript:

Algorithm Efficiency Chapter 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Contents What Is a Good Solution? Measuring the Efficiency of Algorithms Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

What Is a Good Solution? Criterion A solution is good if the total cost it incurs over all phases of its life is minimal. Keep in mind, efficiency is only one aspect of a solution’s cost Note: Relative importance of various components of a solution’s cost has changed since early days of computing. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Measuring Efficiency of Algorithms Comparison of algorithms should focus on significant differences in efficiency Difficulties with comparing programs instead of algorithms How are the algorithms coded? What computer should you use? What data should the programs use? Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Execution Time of Algorithm Traversal of linked nodes – example: Displaying data in linked chain of n nodes requires time proportional to n No need to worry about Linked List for now!! (Kelvin 10/16) Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Algorithm Growth Rates Measure algorithm’s time requirement as a function of problem size Compare algorithm efficiencies for large problems Look only at significant differences. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Algorithm Growth Rates FIGURE 10-1 Time requirements as a function of the problem size n Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Analysis and Big O Notation Definition: 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 . Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Analysis and Big O Notation FIGURE 10-2 The graphs of 3  n2 and n2 - 3  n + 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Analysis and Big O Notation Order of growth of some common functions Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Analysis and Big O Notation FIGURE 10-3 A comparison of growth-rate functions: (a) in tabular form Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Analysis and Big O Notation FIGURE 10-3 A comparison of growth-rate functions: (a) in graphical form Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Properties of Growth-Rate Functions Ignore low-order terms Ignore a multiplicative constant in the high-order term O(f(n)) + O(g(n)) = O(f(n) + g(n)) Be aware of worst case, average case Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Keeping Your Perspective Array-based getEntry is O(1) Link-based getEntry is O(n) Consider how frequently particular ADT operations occur in given application Some seldom-used but critical operations must be efficient Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Keeping Your Perspective If problem size always small, ignore an algorithm’s efficiency Weigh trade-offs between algorithm’s time and memory requirements Compare algorithms for both style and efficiency Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Efficiency of Searching Algorithms Sequential search Worst case O(n) Average case O(n) Best case O(1) Binary search of sorted array Worst case O(log2n) Remember required overhead for keeping array sorted Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

End Chapter 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013