Data Structures. Outline. Introduction. Andres Mendez-Vazquez. December 3, Data Manipulation Examples
|
|
- Philomena Day
- 5 years ago
- Views:
Transcription
1 Data Structures Introduction Andres Mendez-Vazquez December 3, / 53 Outline 1 What the Course is About? Data Manipulation Examples 2 What is a Good Algorithm? Sorting Example A Naive Algorithm Counting Steps About the Worst Case A more realistic step count Definition of Big O Meaning for insertion sort 3 Examples of Complexities Problems Calculating Complexities 2 / 53
2 Introduction Data Manipulation Data structures is concerned with the representation and manipulation of data. Further All programs manipulate data. Thus!!! So, all programs represent data in some way. Data manipulation requires a data structure and an algorithm!!! 4 / 53 So you must go beyond... First Believing that coding is the only think that you need to be a Computer Scientist Coding is only a tool to express our designs, our thoughts!!! Second Assuming that you can get away from mathematics!!! Computer Science is Mathematics at its core!!! 5 / 53
3 Examples Data Bases Using B-trees for fast access to the records!!! 7 / 53 Example Storing Sparse Matrices Sparse Matrix 5x5 Matrix Numeric Elements Empty Elements Why? Reduce the amount memory used for storage!!! 8 / 53
4 Example Shortest Path in a Map 9 / 53 What is the course about? First Understanding Data Structure and Algorithms needed to develop programs for data manipulation. Why? The study of Data Structures and Algorithms is fundamental to Computer Science. 10 / 53
5 In sorting, we want to have the following Rearrange a sequence of numbers 9,3,4,2,1 Into an increasing sequence 1, 2, 3, 4, 9 Or Into a decreasing sequence 9, 4, 3, 2, 1 12 / 53 Notation For now, we will assume that the data It is an array A. Meaning item index Thus If we need to reference elements on the array through an index, we use the following notation A [index] (1) 13 / 53
6 Naive Algorithm What if we do the following 1 Pick an element in the array A. 2 Put that element in the correct position. Thus We will concentrate first in inserting the element in the correct position For this imagine the following We already have an array A = [ ] where - represents null elements. 15 / 53 Thus Where do we start comparing to insert? Ideas? Maybe From the right!!! After all we have space Let us do it with A = [ ] 16 / 53
7 What about the code? What do we use for going through a sequence? Ideas? In addition, we need to make space For the new item. Code p r i v a t e i n t [ ] i n s e r t ( i n t [ ] A, i n t t ){ // E x t r a V a r i a b l e s i n t j ; // I n s e r t i n t o A [ 0 : i 1] f o r ( j = A. l e n g h t 1; j >=0 && t<a [ j ] ; j ){ // s h i f t to t h e r i g h t A [ j +1]=A [ j ] ; } A [ j +1]= t ; r e t u r n A ; } 17 / 53 Ok, We have that...now what? How do we use this piece of code for the insertion sort? Ideas? Problem with the code!! You require that the array where you insert to be sorted!!! Thus How do we solve this problem? Look at this!!! At the Board / 53
8 Then, Insertion Sort works like this First Start with a sequence of size 1. After all an array with one element is sorted!!! Second Repeatedly insert remaining elements Example Sort 7, 3, 5, 6, 1 19 / 53 Final Code Something Notable // S o r t A assume i s f u l l p u b l i c i n t [ ] I n s e r t i o n S o r t ( i n t [ ] A){ // E x t r a Space i n t B [ ] = new i n t [ A. l e n g t h ] ; // I n i t A r r a y B B[0]=A [ 0 ] ; i n t s i z e = 1 ; i n t j, t ; f o r ( i n t i = 1 ; i < A. l e n g t h ; i ++){ t = A [ i ] ; f o r ( j = s i z e 1; j >=0 && t<b [ j ] ; j ) { // s h i f t to t h e r i g h t B [ j +1]=B [ j ] ; } B [ j +1]= t ; s i z e ++; } r e t u r n B ; } 20 / 53
9 Question: Which Complexity You Have with Insertion Sort? After all you have!!! Time Complexity!!! For this, we have Time Complexity Techniques: Count a particular operation Count number of steps Asymptotic complexity 22 / 53 Basically, we will use the second one First Look at this part of the code f o r ( j = s i z e 1; j >=0 && t<b[j] ; j ) B [ j +1]=B [ j ] ; Then How many comparisons are made? 23 / 53
10 The Possible Cases Worst-case count Maximum count Best-case count Minimum count In addition, we have Average Count 25 / 53 Example: Worst-Case For the Code Code, Look at the red compares f o r ( j = s i z e 1; j >=0 && t<b[j] ; j ) B [ j +1]=B [ j ] ; Case I If B = [1, 2, 3, 4] and t = 0 = 4 compares. What about the general case If B = [1, 2, 3,..., i] and t = 0 = i compares. 26 / 53
11 Worst-Case For An Almost Final Version Simplified Version \\Remember s i z e i s t h e s i z e o f B f o r ( i = 1 ; i < A. l e n g t h ; i++ ) f o r ( j = s i z e 1; j >=0 && t<b[j] ; j ) B [ j +1]=B [ j ] ; Worst Case for the Outer Loop 1 Outer loop takes n steps if A.length== n What about the inner loop? Answer Number of steps in the inner loop = size+1 27 / 53 What is the range of j? Very Simple For the first step j = 1 1 = Number of Steps = 2 (0 and -1) For the last step j = n 1 1 = Number of Steps = n Here, we have n 1 passing statements and 1 that gets us out the loop. Total Compares n = n (n + 1) 2 1 (2) 28 / 53
12 A more realistic step count Counting when A.length = n // S o r t A assume i s f u l l p u b l i c i n t [ ] I n s e r t i o n S o r t ( i n t [ ] A){ Step // I n i t i a l V a r i a b l e s 0 i n t B [ ] = new i n t [ A. l e n g t h ] ; 1 i n t s i z e = 1 ; 1 i n t i, j, t ; 1 // I n i t i a l i z e t h e A r r a y B 0 B[0]=A [ 0 ] ; 1 f o r ( i = 1 ; i < A. l e n g t h ; i ++){ n t = A [ i ] ; n 1 f o r ( j=s i z e 1; j >=0&&t<B [ j ] ; j ) i +1 { // s h i f t to t h e r i g h t 0 B [ j +1]=B [ j ] ; } i B [ j +1]= t ; n 1 s i z e ++; n 1 } r e t u r n B ; 1 } 30 / 53 The Result Step count for body of for loop is The summation n 1 n (n 1) + n + (i + 1) + (i) (3) They have the quadratic terms n 2. Complexity Insertion sort complexity is O ( n 2) i=1 j=1 31 / 53
13 Definition of Big O Definition For a given function g(n) O(g(n)) ={f (n) There exists c > 0 and n 0 > 0 s.t. 0 f (n) cg(n) n n 0 } Graphically 33 / 53 What? The term n 0 It tells you when for the following n s you will have that f (n) cg(n) What about the so called c It can be seen a way to increase or decrease the height of the function!!! 34 / 53
14 What does this means for insertion sort? We have n 1 n (n 1) + n + (i + 1) + (i) = n + n (n 1) 2 i=1 j=1 n (n 1) + n 1 + = n + n(n 1) =... n 2 + 4n + 2 n 2 + 4n 2 + 2n 2 Thus n 2 + 4n + 2 7n 2 (4) With T insertion (n) = n 2 + 4n + 2 describing the number of steps for insertion when we have n numbers. 36 / 53 Actually For n 0 = = 14 < = 28 (5) Graphically 37 / 53
15 Meaning First Time or number of operations does not exceed cn 2 for a constant c on any input of size n (n suitably large). Questions Is O(n 2 ) too much time? Is the algorithm practical? For this imagine, we have a machine able to make 10 9 instructions/seconds 38 / 53 Then We have the following n n n log n n 2 n 3 n micros 10 micros 1 milis 1 second 17 minutes 10, micros 130 micros 100 milis 17 minutes 116 days milis 20 milis 17 minutes 32 years years It is much worse n n 10 2 n years years 10,000?????? 10 6?????????? The Reign of the Non Polynomial Algorithms 39 / 53
16 Basically These complexities allow us to compare algorithms You can compare 2 algorithms having different asymptotic complexity For example two types of sorting algorithms with O(n) and O(n 2 ) complexities. However This notation does not account for constant factors. For example For many cases of n, n is much worse than n / 53 A Huge Problem for calculating complexities The memory hierachy: Slower Memories as further you go from the CORE L3 Cache To Main Memory L2 Cache L1i Cache L1i Cache L2 Cache L1d Cache CPU Core 1 CPU Core 2 L1d Cache L1d Cache P-to-P CPU Core 3 CPU Core 4 L1d Cache L2 Cache L1i Cache L1i Cache L2 Cache Note: I will recommend to read What Every Programmer Should Know About Memory by Ulrich Drepper Red Hat, Inc. 42 / 53
17 Examples B-Trees are generalized Binary Search Trees With element in the nodes sorted in increasing order 43 / 53 Example We can improve B-Tree policies to find indexes inside nodes by Binary Search Linear Search 44 / 53
18 Here, a reasonable assumption!!! Classic Analysis Binary Search Faster than Linear Search!!! Node Structure a (i) a (i+1) i However, Core i7 has prefetching Thus, for a certain size of a node, linear searching will be faster than binary search due to prefetching hardware!!! 45 / 53 Main Problem Main problem Our analysis does not account for this difference in memory access times. Thus What do we need? What? A way to measure the time in our Java programs. 46 / 53
19 What do we need? Data 1 Worst-case data 2 Best-case data 3 Average-case data In addition A way to measure the time in a machine and language Problem We require certain degree of accuracy that we do not have 47 / 53 What do we have? Java Instruction System.currentTimeMillis() It returns the current time in milliseconds. The granularity of the value depends on the underlying operating system and may be larger. Yes!!! The accuracy is not great for it!!! 48 / 53
20 Possible Solution What to do? Ideas? What about this logic? 1 Assume that you have a 100 millisecond accuracy in a Linux System. 2 Assume that you want to have a measurement error of 10%. 3 What do we do? 49 / 53 Simple Idea for Accuracy If we want to have a 10% error We need to measure 100% of the total time. In the case of 100 milliseconds We need to measure operations for 1000 milliseconds!!! Or trueelapsedtime = finishtime - starttime +/- Error 50 / 53
21 First Solution Repeat method until you accumulate enough time For this, if you have 100 milliseconds for the code to be measured, then you need a Time 1000 milliseconds to obtain an accuracy of 10%. First we device the timing code // g i v e s time i n m i l l i s e c o n d s s i n c e 1/1/1970 GMT l o n g s t a r t T i m e = System. c u r r e n t T i m e M i l l i s ( ) ; // code to be timed comes h e r e l o n g e l a p s e d T i m e = System. c u r r e n t T i m e M i l l i s () s t a r t T i m e ; 51 / 53 What is the problem with this Solution? PROBLEM!!! l o n g s t a r t T i m e = System. c u r r e n t T i m e M i l l i s ( ) ; l o n g c o u n t e r ; // Put code to i n i t i a l i z e a [ ] h e r e // Go f o r randomized a r r a y do{ c o u n t e r ++; SomeClass. I n s e r t i o n S o r t (A ) ; } w h i l e ( System. c u r r e n t T i m e M i l l i s () s t a r t T i m e < 1000) l o n g e l a p s e d T i m e = System. c u r r e n t T i m e M i l l i s () s t a r t T i m e ; f l o a t timeformethod = ( ( f l o a t ) e l a p s e d T i m e )/ c o u n t e r ; 52 / 53
22 Fix Solution l o n g s t a r t T i m e = System. c u r r e n t T i m e M i l l i s ( ) ; l o n g c o u n t e r ; do{ c o u n t e r ++; // Move t h e code to i n i t i a l i z e a [ ] h e r e // Go f o r randomized a r r a y SomeClass. I n s e r t i o n S o r t (A ) ; } w h i l e ( System. c u r r e n t T i m e M i l l i s () s t a r t T i m e < 1000) l o n g e l a p s e d T i m e = System. c u r r e n t T i m e M i l l i s () s t a r t T i m e ; f l o a t timeformethod = ( ( f l o a t ) e l a p s e d T i m e )/ c o u n t e r ; 53 / 53
Growth of Functions (CLRS 2.3,3)
Growth of Functions (CLRS 2.3,3) 1 Review Last time we discussed running time of algorithms and introduced the RAM model of computation. Best-case running time: the shortest running time for any input
More informationMeasuring Goodness of an Algorithm. Asymptotic Analysis of Algorithms. Measuring Efficiency of an Algorithm. Algorithm and Data Structure
Measuring Goodness of an Algorithm Asymptotic Analysis of Algorithms EECS2030 B: Advanced Object Oriented Programming Fall 2018 CHEN-WEI WANG 1. Correctness : Does the algorithm produce the expected output?
More informationFundamentals of Programming. Efficiency of algorithms November 5, 2017
15-112 Fundamentals of Programming Efficiency of algorithms November 5, 2017 Complexity of sorting algorithms Selection Sort Bubble Sort Insertion Sort Efficiency of Algorithms A computer program should
More informationcsci 210: Data Structures Program Analysis
csci 210: Data Structures Program Analysis Summary Topics commonly used functions analysis of algorithms experimental asymptotic notation asymptotic analysis big-o big-omega big-theta READING: GT textbook
More informationAnalysis of Algorithm Efficiency. Dr. Yingwu Zhu
Analysis of Algorithm Efficiency Dr. Yingwu Zhu Measure Algorithm Efficiency Time efficiency How fast the algorithm runs; amount of time required to accomplish the task Our focus! Space efficiency Amount
More informationCSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms
(2017F) Lecture4: Analysis of Algorithms Daijin Kim CSE, POSTECH dkim@postech.ac.kr Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically
More informationcsci 210: Data Structures Program Analysis
csci 210: Data Structures Program Analysis 1 Summary Summary analysis of algorithms asymptotic analysis big-o big-omega big-theta asymptotic notation commonly used functions discrete math refresher READING:
More informationAnalysis of Algorithms
Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Analysis of Algorithms Input Algorithm Analysis
More informationComputational Complexity
Computational Complexity S. V. N. Vishwanathan, Pinar Yanardag January 8, 016 1 Computational Complexity: What, Why, and How? Intuitively an algorithm is a well defined computational procedure that takes
More informationData Structures and Algorithms Running time and growth functions January 18, 2018
Data Structures and Algorithms Running time and growth functions January 18, 2018 Measuring Running Time of Algorithms One way to measure the running time of an algorithm is to implement it and then study
More informationLecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan
Lecture 2 More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Announcements Assignment #1 is posted online It is directly related to MCSS which we will be talking about today or Monday. There are
More informationLecture 1: Asymptotics, Recurrences, Elementary Sorting
Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running
More informationProblem. Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26
Binary Search Introduction Problem Problem Given a dictionary and a word. Which page (if any) contains the given word? 3 / 26 Strategy 1: Random Search Randomly select a page until the page containing
More informationAnalysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College
Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Why analysis? We want to predict how the algorithm will behave (e.g. running time) on arbitrary inputs, and how it will
More informationComputer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2
Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula
More informationComputer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2
Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula
More informationCS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms
CS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions
More informationCh 01. Analysis of Algorithms
Ch 01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T.
More informationCS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms
CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions
More informationEnumerate all possible assignments and take the An algorithm is a well-defined computational
EMIS 8374 [Algorithm Design and Analysis] 1 EMIS 8374 [Algorithm Design and Analysis] 2 Designing and Evaluating Algorithms A (Bad) Algorithm for the Assignment Problem Enumerate all possible assignments
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationLecture 10: Big-Oh. Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette. January 27, 2014
Lecture 10: Big-Oh Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette January 27, 2014 So far we have talked about O() informally, as a way of capturing the worst-case computation
More informationP, NP, NP-Complete, and NPhard
P, NP, NP-Complete, and NPhard Problems Zhenjiang Li 21/09/2011 Outline Algorithm time complicity P and NP problems NP-Complete and NP-Hard problems Algorithm time complicity Outline What is this course
More informationCh01. Analysis of Algorithms
Ch01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T. Goodrich
More informationData Structures and Algorithms
Data Structures and Algorithms Autumn 2018-2019 Outline 1 Algorithm Analysis (contd.) Outline Algorithm Analysis (contd.) 1 Algorithm Analysis (contd.) Growth Rates of Some Commonly Occurring Functions
More informationBig-O Notation and Complexity Analysis
Big-O Notation and Complexity Analysis Jonathan Backer backer@cs.ubc.ca Department of Computer Science University of British Columbia May 28, 2007 Problems Reading: CLRS: Growth of Functions 3 GT: Algorithm
More informationWhat is Performance Analysis?
1.2 Basic Concepts What is Performance Analysis? Performance Analysis Space Complexity: - the amount of memory space used by the algorithm Time Complexity - the amount of computing time used by the algorithm
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationCISC 235: Topic 1. Complexity of Iterative Algorithms
CISC 235: Topic 1 Complexity of Iterative Algorithms Outline Complexity Basics Big-Oh Notation Big-Ω and Big-θ Notation Summations Limitations of Big-Oh Analysis 2 Complexity Complexity is the study of
More informationCSE 241 Class 1. Jeremy Buhler. August 24,
CSE 41 Class 1 Jeremy Buhler August 4, 015 Before class, write URL on board: http://classes.engineering.wustl.edu/cse41/. Also: Jeremy Buhler, Office: Jolley 506, 314-935-6180 1 Welcome and Introduction
More informationAlgorithm. Executing the Max algorithm. Algorithm and Growth of Functions Benchaporn Jantarakongkul. (algorithm) ก ก. : ก {a i }=a 1,,a n a i N,
Algorithm and Growth of Functions Benchaporn Jantarakongkul 1 Algorithm (algorithm) ก ก ก ก ก : ก {a i }=a 1,,a n a i N, ก ก : 1. ก v ( v ก ก ก ก ) ก ก a 1 2. ก a i 3. a i >v, ก v ก a i 4. 2. 3. ก ก ก
More informationBig O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013
/4/3 Administrative Big O David Kauchak cs3 Spring 3 l Assignment : how d it go? l Assignment : out soon l CLRS code? l Videos Insertion-sort Insertion-sort Does it terminate? /4/3 Insertion-sort Loop
More informationdata structures and algorithms lecture 2
data structures and algorithms 2018 09 06 lecture 2 recall: insertion sort Algorithm insertionsort(a, n): for j := 2 to n do key := A[j] i := j 1 while i 1 and A[i] > key do A[i + 1] := A[i] i := i 1 A[i
More informationCS 310 Advanced Data Structures and Algorithms
CS 310 Advanced Data Structures and Algorithms Runtime Analysis May 31, 2017 Tong Wang UMass Boston CS 310 May 31, 2017 1 / 37 Topics Weiss chapter 5 What is algorithm analysis Big O, big, big notations
More informationAsymptotic Running Time of Algorithms
Asymptotic Complexity: leading term analysis Asymptotic Running Time of Algorithms Comparing searching and sorting algorithms so far: Count worst-case of comparisons as function of array size. Drop lower-order
More informationASYMPTOTIC COMPLEXITY SEARCHING/SORTING
Quotes about loops O! Thou hast damnable iteration and art, indeed, able to corrupt a saint. Shakespeare, Henry IV, Pt I, 1 ii Use not vain repetition, as the heathen do. Matthew V, 48 Your if is the only
More informationTheory of Computation
Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation 1 / 38 Lecture 21: Overview Big-Oh notation. Little-o notation. Time Complexity Classes Non-deterministic TMs The Class
More informationBig O (Asymptotic Upper Bound)
Big O (Asymptotic Upper Bound) Linear search takes O(n) time. Binary search takes O(lg(n)) time. (lg means log 2 ) Bubble sort takes O(n 2 ) time. n 2 + 2n + 1 O(n 2 ), n 2 + 2n + 1 O(n) Definition: f
More informationCIS 121. Analysis of Algorithms & Computational Complexity. Slides based on materials provided by Mary Wootters (Stanford University)
CIS 121 Analysis of Algorithms & Computational Complexity Slides based on materials provided by Mary Wootters (Stanford University) Today Sorting: InsertionSort vs MergeSort Analyzing the correctness of
More informationDivide-and-Conquer Algorithms Part Two
Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller
More informationSpace Complexity of Algorithms
Space Complexity of Algorithms So far we have considered only the time necessary for a computation Sometimes the size of the memory necessary for the computation is more critical. The amount of memory
More informationIntroduction. An Introduction to Algorithms and Data Structures
Introduction An Introduction to Algorithms and Data Structures Overview Aims This course is an introduction to the design, analysis and wide variety of algorithms (a topic often called Algorithmics ).
More informationAlgorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc.
Algorithms Analysis Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc. Algorithms analysis tends to focus on time: Techniques for measuring
More informationGreat Theoretical Ideas in Computer Science. Lecture 7: Introduction to Computational Complexity
15-251 Great Theoretical Ideas in Computer Science Lecture 7: Introduction to Computational Complexity September 20th, 2016 What have we done so far? What will we do next? What have we done so far? > Introduction
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Based
More information5 + 9(10) + 3(100) + 0(1000) + 2(10000) =
Chapter 5 Analyzing Algorithms So far we have been proving statements about databases, mathematics and arithmetic, or sequences of numbers. Though these types of statements are common in computer science,
More informationAsymptotic Analysis of Algorithms. Chapter 4
Asymptotic Analysis of Algorithms Chapter 4 Overview Motivation Definition of Running Time Classifying Running Time Asymptotic Notation & Proving Bounds Algorithm Complexity vs Problem Complexity Overview
More informationCS173 Running Time and Big-O. Tandy Warnow
CS173 Running Time and Big-O Tandy Warnow CS 173 Running Times and Big-O analysis Tandy Warnow Today s material We will cover: Running time analysis Review of running time analysis of Bubblesort Review
More informationAlgorithms Design & Analysis. Analysis of Algorithm
Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of
More informationAnalysis of Algorithms
October 1, 2015 Analysis of Algorithms CS 141, Fall 2015 1 Analysis of Algorithms: Issues Correctness/Optimality Running time ( time complexity ) Memory requirements ( space complexity ) Power I/O utilization
More informationAlgorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang
Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Last class Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive
More informationData Structures in Java
Data Structures in Java Lecture 21: Introduction to NP-Completeness 12/9/2015 Daniel Bauer Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways
More informationMA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3
MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents
More informationThe Time Complexity of an Algorithm
Analysis of Algorithms The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input. Purpose To estimate how long a program will run. To estimate the largest input
More informationLecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole.
Lecture 1: Asymptotic Complexity 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole. Announcements TA office hours officially start this week see
More informationAsymptotic Analysis. Thomas A. Anastasio. January 7, 2004
Asymptotic Analysis Thomas A. Anastasio January 7, 004 1 Introduction As a programmer, you often have a choice of data structures and algorithms. Choosing the best one for a particular job involves, among
More informationThe Time Complexity of an Algorithm
CSE 3101Z Design and Analysis of Algorithms The Time Complexity of an Algorithm Specifies how the running time depends on the size of the input. Purpose To estimate how long a program will run. To estimate
More informationData Structures and Algorithms. Asymptotic notation
Data Structures and Algorithms Asymptotic notation Estimating Running Time Algorithm arraymax executes 7n 1 primitive operations in the worst case. Define: a = Time taken by the fastest primitive operation
More informationDefine Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 417: Algorithms and Computational Complexity. Winter 2007 Larry Ruzzo
CSE 417: Algorithms and Computational 2: Analysis Winter 2007 Larry Ruzzo Define Efficiency Runs fast on typical real problem instances Pro: sensible, bottom-line-oriented Con: moving target (diff computers,
More informationLECTURE NOTES ON DESIGN AND ANALYSIS OF ALGORITHMS
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY LECTURE NOTES ON DESIGN AND ANALYSIS OF ALGORITHMS Department of Computer Science and Engineering 1 UNIT 1 Basic Concepts Algorithm An Algorithm is a finite
More informationCSC236 Week 3. Larry Zhang
CSC236 Week 3 Larry Zhang 1 Announcements Problem Set 1 due this Friday Make sure to read Submission Instructions on the course web page. Search for Teammates on Piazza Educational memes: http://www.cs.toronto.edu/~ylzhang/csc236/memes.html
More informationReview Of Topics. Review: Induction
Review Of Topics Asymptotic notation Solving recurrences Sorting algorithms Insertion sort Merge sort Heap sort Quick sort Counting sort Radix sort Medians/order statistics Randomized algorithm Worst-case
More informationAlgorithms and Their Complexity
CSCE 222 Discrete Structures for Computing David Kebo Houngninou Algorithms and Their Complexity Chapter 3 Algorithm An algorithm is a finite sequence of steps that solves a problem. Computational complexity
More informationDefining Efficiency. 2: Analysis. Efficiency. Measuring efficiency. CSE 421: Intro Algorithms. Summer 2007 Larry Ruzzo
CSE 421: Intro Algorithms 2: Analysis Summer 2007 Larry Ruzzo Defining Efficiency Runs fast on typical real problem instances Pro: sensible, bottom-line-oriented Con: moving target (diff computers, compilers,
More informationTheory of Computation
Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation 1 / 33 Lecture 20: Overview Incompressible strings Minimal Length Descriptions Descriptive Complexity Dr. Sarmad Abbasi
More informationProblem-Solving via Search Lecture 3
Lecture 3 What is a search problem? How do search algorithms work and how do we evaluate their performance? 1 Agenda An example task Problem formulation Infrastructure for search algorithms Complexity
More informationAsymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2
Asymptotic Analysis Slides by Carl Kingsford Jan. 27, 2014 AD Chapter 2 Independent Set Definition (Independent Set). Given a graph G = (V, E) an independent set is a set S V if no two nodes in S are joined
More informationData Structures and Algorithms
Data Structures and Algorithms Spring 2017-2018 Outline 1 Sorting Algorithms (contd.) Outline Sorting Algorithms (contd.) 1 Sorting Algorithms (contd.) Analysis of Quicksort Time to sort array of length
More informationComputer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms
Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Limitations of Algorithms We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds
More informationRunning Time. Overview. Case Study: Sorting. Sorting problem: Analysis of algorithms: framework for comparing algorithms and predicting performance.
Running Time Analysis of Algorithms As soon as an Analytic Engine exists, it will necessarily guide the future course of the science. Whenever any result is sought by its aid, the question will arise -
More informationLecture 2. Fundamentals of the Analysis of Algorithm Efficiency
Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?
More informationMathematical Background. Unsigned binary numbers. Powers of 2. Logs and exponents. Mathematical Background. Today, we will review:
Mathematical Background Mathematical Background CSE 373 Data Structures Today, we will review: Logs and eponents Series Recursion Motivation for Algorithm Analysis 5 January 007 CSE 373 - Math Background
More informationLimitations of Algorithm Power
Limitations of Algorithm Power Objectives We now move into the third and final major theme for this course. 1. Tools for analyzing algorithms. 2. Design strategies for designing algorithms. 3. Identifying
More informationHow many hours would you estimate that you spent on this assignment?
The first page of your homework submission must be a cover sheet answering the following questions. Do not leave it until the last minute; it s fine to fill out the cover sheet before you have completely
More informationCS Data Structures and Algorithm Analysis
CS 483 - Data Structures and Algorithm Analysis Lecture II: Chapter 2 R. Paul Wiegand George Mason University, Department of Computer Science February 1, 2006 Outline 1 Analysis Framework 2 Asymptotic
More informationCS 4104 Data and Algorithm Analysis. Recurrence Relations. Modeling Recursive Function Cost. Solving Recurrences. Clifford A. Shaffer.
Department of Computer Science Virginia Tech Blacksburg, Virginia Copyright c 2010,2017 by Clifford A. Shaffer Data and Algorithm Analysis Title page Data and Algorithm Analysis Clifford A. Shaffer Spring
More informationIntroduction. How can we say that one algorithm performs better than another? Quantify the resources required to execute:
Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Section 2.3 of Rosen cse235@cse.unl.edu Introduction How can we say that one algorithm
More informationAlgorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples
Enough Mathematical Appetizers! Algorithms What is an algorithm? Let us look at something more interesting: Algorithms An algorithm is a finite set of precise instructions for performing a computation
More informationComplexity Theory Part I
Complexity Theory Part I Problem Problem Set Set 77 due due right right now now using using a late late period period The Limits of Computability EQ TM EQ TM co-re R RE L D ADD L D HALT A TM HALT A TM
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 3 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 19, 2007 Last Time Lots of funky math Playing
More informationThis chapter covers asymptotic analysis of function growth and big-o notation.
Chapter 14 Big-O This chapter covers asymptotic analysis of function growth and big-o notation. 14.1 Running times of programs An important aspect of designing a computer programs is figuring out how well
More informationCpt S 223. School of EECS, WSU
Algorithm Analysis 1 Purpose Why bother analyzing code; isn t getting it to work enough? Estimate time and memory in the average case and worst case Identify bottlenecks, i.e., where to reduce time Compare
More informationAnalysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes
Analysis of Algorithms Single Source Shortest Path Andres Mendez-Vazquez November 9, 01 1 / 108 Outline 1 Introduction Introduction and Similar Problems General Results Optimal Substructure Properties
More informationData Structures and Algorithms CSE 465
Data Structures and Algorithms CSE 465 LECTURE 3 Asymptotic Notation O-, Ω-, Θ-, o-, ω-notation Divide and Conquer Merge Sort Binary Search Sofya Raskhodnikova and Adam Smith /5/0 Review Questions If input
More informationLecture 2: Asymptotic Analysis of Algorithms
Lecture 2: Asymptotic Analysis of Algorithms Goodrich & Tamassia, Chapter 4-1 - The Importance of Asymptotic Analysis Thu, 26 Jul 2001 00:50:03 +0300 Subject:
More informationGreat Theoretical Ideas in Computer Science. Lecture 9: Introduction to Computational Complexity
15-251 Great Theoretical Ideas in Computer Science Lecture 9: Introduction to Computational Complexity February 14th, 2017 Poll What is the running time of this algorithm? Choose the tightest bound. def
More informationAnalysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort
Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map
More informationTopic 17. Analysis of Algorithms
Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm
More informationReminder of Asymptotic Notation. Inf 2B: Asymptotic notation and Algorithms. Asymptotic notation for Running-time
1 / 18 Reminder of Asymptotic Notation / 18 Inf B: Asymptotic notation and Algorithms Lecture B of ADS thread Let f, g : N! R be functions. We say that: I f is O(g) if there is some n 0 N and some c >
More informationCSE 417: Algorithms and Computational Complexity
CSE 417: Algorithms and Computational Complexity Lecture 2: Analysis Larry Ruzzo 1 Why big-o: measuring algorithm efficiency outline What s big-o: definition and related concepts Reasoning with big-o:
More informationData Structures and Algorithms Chapter 2
1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples
More informationAsymptotic Algorithm Analysis & Sorting
Asymptotic Algorithm Analysis & Sorting (Version of 5th March 2010) (Based on original slides by John Hamer and Yves Deville) We can analyse an algorithm without needing to run it, and in so doing we can
More informationWhen we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:
CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe
More informationBig , and Definition Definition
Big O, Ω, and Θ Big-O gives us only a one-way comparison; if f is O(g) then g eventually is bigger than f from that point on, but in fact f could be very small in comparison. Example; 3n is O(2 2n ). We
More informationAlgorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count
Types of formulas for basic operation count Exact formula e.g., C(n) = n(n-1)/2 Algorithms, Design and Analysis Big-Oh analysis, Brute Force, Divide and conquer intro Formula indicating order of growth
More information- Why aren t there more quantum algorithms? - Quantum Programming Languages. By : Amanda Cieslak and Ahmana Tarin
- Why aren t there more quantum algorithms? - Quantum Programming Languages By : Amanda Cieslak and Ahmana Tarin Why aren t there more quantum algorithms? there are only a few problems for which quantum
More informationWhat we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt
Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency
More informationSorting algorithms. Sorting algorithms
Properties of sorting algorithms A sorting algorithm is Comparison based If it works by pairwise key comparisons. In place If only a constant number of elements of the input array are ever stored outside
More information