Algorithmic complexity: Speed of algorithms

Slides:



Advertisements
Similar presentations
Order of complexity. Consider four algorithms 1.The naïve way of adding the numbers up to n 2.The smart way of adding the numbers up to n 3.A binary search.
Advertisements

Growth-rate Functions
Introduction to Computer Science Theory
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Recursion Michael Ernst UW CSE 140 To seal: moisten flap, fold over, and seal.
Computer Science 112 Fundamentals of Programming II Bucket Sort: An O(N) Sort Algorithm.
Recursion Michael Ernst CSE 190p University of Washington To seal: moisten flap, fold over, and seal.
Advanced Topics in Algorithms and Data Structures Page 1 Parallel merging through partitioning The partitioning strategy consists of: Breaking up the given.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
Chapter 11 Sorting and Searching. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Examine the linear search and.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
Searching/Sorting Introduction to Computing Science and Programming I.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Data Structure Algorithm Analysis TA: Abbas Sarraf
COMP s1 Computing 2 Complexity
(C) 2010 Pearson Education, Inc. All rights reserved. Java How to Program, 8/e.
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.
Searching CS 105 See Section 14.6 of Horstmann text.
 2005 Pearson Education, Inc. All rights reserved Searching and Sorting.
 Pearson Education, Inc. All rights reserved Searching and Sorting.
Searching. RHS – SOC 2 Searching A magic trick: –Let a person secretly choose a random number between 1 and 1000 –Announce that you can guess the number.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
Big Oh Algorithms are compared to each other by expressing their efficiency in big-oh notation Big O notation is used in Computer Science to describe the.
SortingBigOh Sorting and "Big Oh" Adapted for ASFA from a presentation by: Barb Ericson Georgia Tech Aug 2007 ASFA AP Computer Science.
SortingBigOh ASFA AP Computer Science A. Big-O refers to the order of an algorithm runtime growth in relation to the number of items I. O(l) - constant.
Sorting.
Announcements: Project 5 Everything we have been learning thus far will enable us to solve interesting problems Project 5 will focus on applying the skills.
1 5. Abstract Data Structures & Algorithms 5.6 Algorithm Evaluation.
CS 206 Introduction to Computer Science II 09 / 18 / 2009 Instructor: Michael Eckmann.
CS 206 Introduction to Computer Science II 01 / 30 / 2009 Instructor: Michael Eckmann.
CS 150: Analysis of Algorithms. Goals for this Unit Begin a focus on data structures and algorithms Understand the nature of the performance of algorithms.
Searching Topics Sequential Search Binary Search.
Search Algorithms Written by J.J. Shepherd. Sequential Search Examines each element one at a time until the item searched for is found or not found Simplest.
Searching CS 110: Data Structures and Algorithms First Semester,
Prof. Amr Goneid, AUC1 CSCE 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 3. Introduction to the Analysis of Algorithms.
1 Algorithms Searching and Sorting Algorithm Efficiency.
1 5. Abstract Data Structures & Algorithms 5.6 Algorithm Evaluation.
Algorithmic complexity: Speed of algorithms
CMPT 438 Algorithms.
Design and Analysis of Algorithms
16 Searching and Sorting.
Sorting and "Big Oh" ASFA AP Computer Science A SortingBigOh.
May 17th – Comparison Sorts
Algorithmic complexity: Speed of algorithms
Algorithmic Efficency
Reasons to study Data Structures & Algorithms
Introduction to complexity
Computer Science 112 Fundamentals of Programming II
Sorting by Tammy Bailey
David Kauchak CS52 – Spring 2015
Teach A level Computing: Algorithms and Data Structures
10.3 Bubble Sort Chapter 10 - Sorting.
Searching CSCE 121 J. Michael Moore.
Algorithm design and Analysis
Chapter 12: Analysis of Algorithms
MSIS 655 Advanced Business Applications Programming
CS 201 Fundamental Structures of Computer Science
QuickSort Previous slides based on ones by Ethan Apter & Marty Stepp
Algorithmic complexity: Speed of algorithms
Reasons to study Data Structures & Algorithms
Searching, Sorting, and Asymptotic Complexity
Searching, Sorting, and Asymptotic Complexity
Algorithmic complexity: Speed of algorithms
Analysis of Algorithms
Algorithmic complexity: Speed of algorithms
Insertion Sort and Shell Sort
Quicksort and selection
Searching.
Data Structures & Programming
Presentation transcript:

Algorithmic complexity: Speed of algorithms Michael Ernst CSE 140 University of Washington

How fast does your program run? Usually, this does not matter Correctness trumps speed Computer time is much cheaper than human time The cost of your program depends on: Time to write and verify it High cost: salaries Time to run it Low cost: electricity An inefficient program may give results faster

Sometimes, speed does matter Ridiculously inefficient algorithms Very large datasets Google: 46 billion pages indexed (2011) 3 billion searches per day (2012) = 150,000,000,000,000,000,000 pages searched per day http://www.statisticbrain.com/total-number-of-pages-indexed-by-google/

Example: Processing pairs def make_pairs(list1, list2): """Return a list of pairs. Each pair is made of corresponding elements of list1 and list2. list1 and list2 must be of the same length.""" … assert make_pairs([100, 200], [101, 201]) == [[100, 101], [200, 201]] 2 nested loops vs. 1 loop Quadratic vs. linear time

Searching Any list vs. a sorted list Linear vs. logarithmic time def search(n, list): """Return index of value in list. The value must be in the list.""" … Any list vs. a sorted list Linear vs. logarithmic time

Sorting selection sort vs. quicksort def sort(l): """Return a sorted version of the input list. The input list is not modified.""" … assert sort([3, 1, 4, 1, 5, 9, 2, 6, 5]) == [1, 1, 2, 3, 4, 5, 5, 6, 9] selection sort vs. quicksort 2 nested loops vs. recursive decomposition time: quadratic (n2) vs. logarithmic (n log n)