Performance The need for speed.

Slides:



Advertisements
Similar presentations
Introduction to Computer Science Theory
Advertisements

Chapter 3: The Efficiency of Algorithms Invitation to Computer Science, Java Version, Third Edition.
Algorithm Analysis (Big O) CS-341 Dick Steflik. Complexity In examining algorithm efficiency we must understand the idea of complexity –Space complexity.
Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
Sorting and Searching. Searching List of numbers (5, 9, 2, 6, 3, 4, 8) Find 3 and tell me where it was.
CS107 Introduction to Computer Science
Chapter 3: The Efficiency of Algorithms Invitation to Computer Science, C++ Version, Third Edition Additions by Shannon Steinfadt SP’05.
Cmpt-225 Algorithm Efficiency.
Chapter 3: The Efficiency of Algorithms Invitation to Computer Science, C++ Version, Fourth Edition.
Concept of Basic Time Complexity Problem size (Input size) Time complexity analysis.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Elementary Data Structures and Algorithms
CS107 Introduction to Computer Science Lecture 7, 8 An Introduction to Algorithms: Efficiency of algorithms.
Counting the Cost Recall linear search & binary search Number of items Worst CaseExpected Case Number of probes (comparisons) LinearBinary Linear Binary.
File Organization Techniques
1 Chapter 24 Developing Efficient Algorithms. 2 Executing Time Suppose two algorithms perform the same task such as search (linear search vs. binary search)
{ 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)
The need for speed. Aren’t today’s computers fast enough? Justification for Better Performance complex applications text  graphics  video real-time.
Analysis of Algorithms
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Arrays Tonga Institute of Higher Education. Introduction An array is a data structure Definitions  Cell/Element – A box in which you can enter a piece.
Reminder Lab 0 Xilinx ISE tutorial Research Send me an if interested Looking for those interested in RC with skills in compilers/languages/synthesis,
Analysis of Algorithms CSCI Previous Evaluations of Programs Correctness – does the algorithm do what it is supposed to do? Generality – does it.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
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.
Computer Science Background for Biologists CSC 487/687 Computing for Bioinformatics Fall 2005.
CSE 373: Data Structures and Algorithms
Complexity © 2014 Project Lead The Way, Inc.Computer Science and Software Engineering.
Chapter VI What should I know about the sizes and speeds of computers?
Algorithm Analysis with Big Oh ©Rick Mercer. Two Searching Algorithms  Objectives  Analyze the efficiency of algorithms  Analyze two classic algorithms.
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.
Algorithm Complexity is concerned about how fast or slow particular algorithm performs.
Section 1: Problem solving AQA Computing A2 © Nelson Thornes 2009 Examples of problems with different time complexities Section 1.2: Comparing algorithms.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
LECTURE 9 CS203. Execution Time Suppose two algorithms perform the same task such as search (linear search vs. binary search) and sorting (selection sort.
Algorithm Analysis 1.
CMPT 438 Algorithms.
19 Searching and Sorting.
Analysis of Algorithms
COP 3503 FALL 2012 Shayan Javed Lecture 15
Performance The need for speed.
Computation.
CS 2210 Discrete Structures Algorithms and Complexity
Performance The need for speed.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Algorithm design and Analysis
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Objective of This Course
Chapter 3: The Efficiency of Algorithms
Lesson 15: Processing Arrays
Winter 2018 CISC101 12/2/2018 CISC101 Reminders
Lecture 6 Efficiency of Algorithms (2) (S&G, ch.3)
CS 2210 Discrete Structures Algorithms and Complexity
Applied Discrete Mathematics Week 6: Computation
Algorithm Efficiency: Searching and Sorting Algorithms
4. Computational Problem Solving
Chapter 3: The Efficiency of Algorithms
Sub-Quadratic Sorting Algorithms
Divide and Conquer Algorithms Part I
Searching, Sorting, and Asymptotic Complexity
Introduction to Data Structures
CSE 373 Data Structures and Algorithms
Algorithm Efficiency and Sorting
CS210- Lecture 2 Jun 2, 2005 Announcements Questions
Indexing, Access and Database System Architecture
CSE 373: Data Structures and Algorithms
Discrete Mathematics CS 2610
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

Performance The need for speed

Aren’t today’s computers fast enough? Justification for Better Performance • complex applications text  graphics  video • real-time applications • computational science Computers are being applied to problems previously solved by humans (e.g., animated motion pictures, Genome sequencing, modeling software for engineering). Jim Lewis modeling software ... Science keeps discovering new fields. The surface area of the earth is 510,065,600 km**2 for the weather forecasting problem.

How do we create faster computation? 1) Faster Hardware 2) Faster Algorithms

How to achieve Moore’s Law? Faster Hardware How to achieve Moore’s Law? Miniaturization limitations: manufacturing & speed of light 2) Multiple processors (supercomputers) Remind students of Moore’s Law. Miniaturization increases speed because of the decrease in the distance electricity must travel. Current manufacturing uses 32nm. (nano=one billionth) laser etching; this is about 1/3000 of the thickness of a human hair) Nanotechnology may lead to growing circuits from molecules. 3) Different technologies optical computers? biological computers? quantum computers?

know which algorithm is How would you know which algorithm is faster? Faster Algorithms empirical approach Benchmarks are one way to analyze algorithms. A benchmark is a program execution used to measure execution time. (a single experimental result) Counting things like instruction executions, variable/memory assignments. Talk about the advantages and disadvantages of benchmarks vs. estimates. The public often trusts benchmarks, but estimates provide more insight. Algorithm speed can be estimated by counting analytic approach ...the number of instructions executed ...the number of variable/memory assignments ...the number of data comparisons

Counting the Cost Recall linear search & binary search Number of items Worst Case Expected Case Number of probes (comparisons) Linear Binary 1 1 1 1 1 7 7 3 3.5 3 63 8 31 1000 10 500 Sometimes these are called “cost estimates” because they approximate cost in computing time. Explain linear search & binary search in the context of finding a student record in a collection of papers sorted by student ID number. This means that for a million items it only takes 20 probes (binary) vs. a half million (linear). N N log2N N/2 log2N Note that 1000 processors could search 1000 items with a single probe per processor.

Algorithm to find the maximum Consider 8 numbers. a b c d e f g h comparisons max of a & b max of c & d max of e & f max of g & h max of a - d max of e - h max of a - h Total number of comparisons?

Algorithm to find the maximum What about 7 numbers. a b c d e f g max of a & b c & d e & f a - d e - g a - g Total number of comparisons?

Algorithm to find the maximum What about 6 numbers. a b c d e f max of a & b c & d e & f a - d a - f Total number of comparisons?

Algorithm to find the maximum Number of items Number of comparisons 1 2 1 6 5 7 6 8 7 20 19 100 99 N N-1 The performance of this algorithm is similar to the linear search. However, using many processors doesn’t help as much for the maximum finder algorithm.

Sorting Algorithms Sorting algorithms rearrange items from smallest to largest (or largest to smallest). One sorting algorithm: - repeatedly find the maximum and move it immediately ahead of all prior maximums. Example (sort 100 values) Step 1 - find the maximum of 100 values 99 comparisons Consider 1000 items and 1000 processors - only 500 have any immediate work, the others must wait until the first round of comparisons are complete. The performance with N processors is essentially the same as binary search. Step 2 - find the maximum of 99 values 98 comparisons Step 3 - find the maximum of 98 values 97 comparisons • • • Total comparisons for sorting 100: 99+98+97+...+1 Total comparisons for sorting N: (N-1)+(N-2)+(N-3)+...+1 = N*(N-1) 2

Comparing Algorithm Performance binary search linear search sorting algorithm Notice that the differences become greater as the number of items increases.

Are there slower algorithms? Consider an algorithm to crack your password. One such algorithm attempts every possible keystroke. Analysis Password length Comparisons 1 94 2 94*94 = 8,836 3 94*94*94 = 830,584 ... ... 8 948 = 6 x 1011 N 94N

Comparing Algorithm Performance password cracker other algorithms

Functional Growth not practical for any large number of items n log2n binary search linear search password cracker sort n log2n n2 94n 1 94 4 2 16 78074896 8 3 64 6 x 1011 12 3.6 144 (note 1) 256 (note 2) 20 4.3 400 24 4.6 576 28 4.8 784 32 5 1024 not practical for any large number of items IBM just recently claimed to break the 1 petaflop barrier note 1 - roughly five years of computation for a 1 petaflop supercomputer note 2 - about 5 times the age of the universe

Important Results #1 -- There are algorithms that take too long to be practically executed on a computer. #2 -- These slow algorithms tend of be of the type that attempt a brute force approach of attempting all possible combinations. #3 -- Moore’s Law cannot fix the problem.

So what do we know? Many algorithms can be processed by modern computers. Some algorithms will be processed with faster computers. Computers will never be fast enough for some algorithms.