CSE332: Data Abstrac0ons Sec%on 2. HyeIn Kim Spring 2014

Similar documents
CSE332: Data Abstrac0ons Sec%on 2. HyeIn Kim Winter 2013

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2

The Time Complexity of an Algorithm

Homework 1 Solutions

The Time Complexity of an Algorithm

Data Structures and Algorithms CSE 465

Asymptotic Analysis 1

Analysis of Algorithm Efficiency. Dr. Yingwu Zhu

CS473 - Algorithms I

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

Agenda. We ve discussed

Data Structures and Algorithms. Asymptotic notation

with the size of the input in the limit, as the size of the misused.

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

i=1 i B[i] B[i] + A[i, j]; c n for j n downto i + 1 do c n i=1 (n i) C[i] C[i] + A[i, j]; c n

CSC236 Week 4. Larry Zhang

CIS 121 Data Structures and Algorithms with Java Spring Big-Oh Notation Monday, January 22/Tuesday, January 23

3.1 Asymptotic notation

CS 4407 Algorithms Lecture 2: Growth Functions

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

Growth of Functions (CLRS 2.3,3)

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2

Lecture 2: Asymptotic Notation CSCI Algorithms I

Lecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole.

COMP 9024, Class notes, 11s2, Class 1

Computational Complexity

Algorithms, Design and Analysis. Order of growth. Table 2.1. Big-oh. Asymptotic growth rate. Types of formulas for basic operation count

Analysis of Algorithms

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0

The Growth of Functions and Big-O Notation

Cpt S 223. School of EECS, WSU

Algorithm efficiency can be measured in terms of: Time Space Other resources such as processors, network packets, etc.

Foundations II: Data Structures and Algorithms

Written Homework #1: Analysis of Algorithms

Md Momin Al Aziz. Analysis of Algorithms. Asymptotic Notations 3 COMP Computer Science University of Manitoba

Principles of Algorithm Analysis

CS Non-recursive and Recursive Algorithm Analysis

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2

CS 4407 Algorithms Lecture 3: Iterative and Divide and Conquer Algorithms

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan

COMP Analysis of Algorithms & Data Structures

Algorithms Design & Analysis. Analysis of Algorithm

CSC2100B Data Structures Analysis

Asymptotic Analysis Cont'd

Data Structures and Algorithms Running time and growth functions January 18, 2018

Ch01. Analysis of Algorithms

CSE 373: Data Structures and Algorithms Pep Talk; Algorithm Analysis. Riley Porter Winter 2017

COMP Analysis of Algorithms & Data Structures

CSC Design and Analysis of Algorithms. Lecture 1

EECS 477: Introduction to algorithms. Lecture 5

An analogy from Calculus: limits

Time complexity analysis

Intro to Theory of Computation

Homework 1 Submission

How many hours would you estimate that you spent on this assignment?

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

Asymptotic Analysis of Algorithms. Chapter 4

Taking Stock. IE170: Algorithms in Systems Engineering: Lecture 3. Θ Notation. Comparing Algorithms

Analysis of Algorithms

Review Asympto&c Bounds

P, NP, NP-Complete, and NPhard

CSE 373: Data Structures and Algorithms. Asymptotic Analysis. Autumn Shrirang (Shri) Mare

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

COMPUTER ALGORITHMS. Athasit Surarerks.

CSE 241 Class 1. Jeremy Buhler. August 24,

CS Data Structures and Algorithm Analysis

Module 1: Analyzing the Efficiency of Algorithms

CS173 Running Time and Big-O. Tandy Warnow

Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA === Homework submission instructions ===

Review Of Topics. Review: Induction

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 1: Introduction

Computational Complexity - Pseudocode and Recursions

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

CSE 531 Homework 1 Solution. Jiayi Xian

Introduction to Algorithms 6.046J/18.401J

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17

Big-O Notation and Complexity Analysis

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms.

Introduction to Algorithms and Asymptotic analysis

Great Theoretical Ideas in Computer Science. Lecture 7: Introduction to Computational Complexity

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

Analysis of Algorithms

Analysis of Multithreaded Algorithms

CSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms

Review 3. Andreas Klappenecker

Recursion. Computational complexity

Analysis of Algorithms

Introduction to Algorithms

CS 161 Summer 2009 Homework #2 Sample Solutions

data structures and algorithms lecture 2

CS 310 Advanced Data Structures and Algorithms

CSCE 222 Discrete Structures for Computing. Review for the Final. Hyunyoung Lee

CS F-01 Algorithm Analysis 1

Data Structures and Algorithms Chapter 2

Fall 2016 Test 1 with Solutions

Transcription:

CSE332: Data Abstrac0ons Sec%on 2 HyeIn Kim Spring 2014

Sec0on Agenda Recurrence Relations Asymptotic Analysis HW1, Project 1 Q&A Project 2 - Introduction - Working in a team - Testing strategies

Recurrence Rela0ons

Recurrence Rela0ons Recursively defines a Sequence - Example: T(n) = T(n-1) + 3, T(1) = 5 ^ Has T(x) in definition Solving Recurrence Relation - Eliminate recursive part in definition = Find Closed Form - Example: T(n) = 3n + 2

Recurrence Rela0ons Expansion Method example - Solve T(n) = T(n-1) + 2n 1, T(1) = 1 T(n) = T(n-1) + 2n 1 T(n-1) = T([n-1]-1) + 2[n-1] 1 = T(n-2) + 2(n-1) 1 T(n-2) = T([n-2]-1) + 2[n-2] 1 = T(n-3) + 2(n-2) 1

Recurrence Rela0ons Expansion Method example T(n) = T(n-1) + 2n 1 T(n-1) = T(n-2) + 2(n-1) 1 T(n-2) = T(n-3) + 2(n-2) 1 T(n) = [T(n-2) + 2(n-1) 1] + 2n 1 = T(n-2) + 2(n-1) + 2n 2 T(n) = [T(n-3) + 2(n-2) 1] + 2(n-1) + 2n 2 = T(n-3) + 2(n-2) + 2(n-1) + 2n 3

Recurrence Rela0ons Expansion Method example T(n) = T(n-1) + 2n 1 T(n) = T(n-2) + 2(n-1) + 2n 2 T(n) = T(n-3) + 2(n-2) + 2(n-1) + 2n 3 T(n) = T(n-k) + [2(n-(k-1)) + + 2(n-1) + 2n] k = T(n-k) + [2(n-k+1) + + 2(n-1) + 2n] k

Recurrence Rela0ons Expansion Method example T(n) = T(n-k) + [2(n-k+1) + + 2(n-1) + 2n] k When expanded all the way down, T(n-k) = T(1) n-k = 1, k = n-1 T(n) = T(n-[n-1]) + [2(n-[n-1]+1) + + 2(n-1) + 2n] [n-1] = T(1) + [2(2) + + 2(n-1) + 2n] n + 1

Recurrence Rela0ons Expansion Method example T(n) = T(1) + [2(2) + + 2(n-1) + 2n] n + 1 = T(1) + 2[2 + + (n-1) + n] n + 1 = T(1) + 2[(n+1)(n/2) -1] n + 1 = T(1) + (n+1)(n) - 2 n + 1 = T(1) + (n 2 +n) n - 1 = T(1) + n 2 1 = 1 + n 2 1 = n 2

Recurrence Rela0ons Expansion Method example Check it! T(n) = T(n-1) + 2n 1, T(1) = 1 T(n) = n 2 T(1) = 1 same as 1 2 T(2) = T(1) + 2(2) 1 = 4 same as 2 2 T(3) = T(2) + 2(3) 1 = 9 same as 3 2 T(4) = T(3) + 2(4) 1 = 16 same as 4 2

Recurrence Rela0ons For Homework Remember to show steps!! - Correct answer with no steps gets no credit a) Show at least 2 expansions of T(n) b) At least 2 representations of T(n), using a) c) Writing T(n) in terms of k, using b) d) Solve for k (show steps!!) e) Plug in k and get the closed form

Asympto0c Analysis

Asympto0c Analysis Describe Limiting behavior of F(n) - Characterize growth rate of F(n) - Use O(g(n)), Ω(g(n)), Θ(g(n)) for set of functions with asymptotic behavior,, & to g(n) Upper Bound: O(n) f(n) O(g(n)) if and only if there exist positive constants c and n 0 such that f(n) c*g(n) for all n 0 n log n O(n)

Asympto0c Analysis Lower Bound: Ω(n) f(n) Ω(g(n)) if and only if there exist positive constants c and n 0 such that c*g(n) f(n) for all n 0 n Tight Bound: Θ(n) f(n) Θ(g(n)) if and only if f(n) Ω(g(n)) and f(n) O(g(n)) n Ω(log n) 5*log 10 n Θ(log n)

Asympto0c Analysis Ordering Growth rates (k = constant) - Ignore Low-Order terms & Coefficients O(k) constant O(log n) logarithmic Increasing O(n) linear Growth rate O(n k ) polynomial O(k n ) exponential (k > 1)

Asympto0c Analysis Ordering Growth rates

Asympto0c Analysis Ordering Growth rates (k, b = constant) - log k n O(n b ) if 1 < k & 0 < b - n k O(b n ) if 0 < k & 1 < b Ordering Example 2n 100 + 10n 2 n/100 + 2 n/270 1000n + log 8 n 23785n 1/2 1000 log 10 n + 1 n/300 n 100 2 n/100 n n 1/2 4 5 3 2 log 10 n 1

Asympto0c Analysis Proof Example 1: f(n) O(g(n)) - Prove or disprove nlog n O(3n) nlog n O(3n), then by definition of Big-O nlog n c*(3n), for 0 < c && 0 < n 0 n (1/3)log n c but as n, log n Finite constant c always greater than log n cannot exist, no matter what n 0 we choose nlog n O(3n)

Asympto0c Analysis Proof Example 2 - Prove or disprove If f(n) O(g(n)) and h(n) O(k(n)), then f(n) + h(n) O(g(n) + k(n))

Homework 1 Q&A Solutions are NOT posted - Any questions?

Project 2 shake- n- bacon

Project 2 Word Frequency Analysis Phase A: Implement 3 ADTs - Due about 2 weeks from now (Thursday April 24 th ) - Word frequency analysis using different DataCounters AVLTree MoveToFrontList FourHeap Heap Sort DataCount data: Apple count: 21 DataCount data: Hamlet count: 67 DataCount data: water count: 33

Project 2 Find Partner Form a 2 person team Not required, but greatly encouraged - Learn from each other - Check each other s style (large fraction of grade!) - Collaborate working experience (You can put it on your resume!) Many had hard time meeting deadline - Don t be spoiled by project 1!

Project 2 Find Partner Form a 2 person team - Use discussion board to find partner https://catalyst.uw.edu/gopost/area/rea2000/129662 - Complete catalyst survey to form team by next Friday April 18 th (Only one survey for a team!) https://catalyst.uw.edu/webq/survey/kainby87/231804 - Anyone wants a partner but don t have one yet?

Project 2 Sharing Code Version Control System - Git, Mercurial, SVN, CVS, Perforce... - Lots of choices (Use whatever you want): http://en.wikipedia.org/wiki/comparison_of_revision_control_software Some posts to help choosing one - Choosing a Version Control: Beginners Tour http://www.codeproject.com/articles/431125/choosing-a-version-control-system-a-beginners-tour - Review of 7 Version Control Systems http://www.smashingmagazine.com/2008/09/18/the-top-7-open-source-version-control-systems/ - What is your favorite version control system? http://programmers.stackexchange.com/questions/940/what-are-your-favorite-version-control-systems

Project 2 Sharing Code Repository: Where you store your code - Your machine - Shared directory in attu (you need to request one) - Web based repository (should be private!) Bitbucket: https://bitbucket.org/ GitHub: https://github.com/

Project 2 Sharing Code Useful tutorials - Bitbucket 101 https://confluence.atlassian.com/display/bitbucket/bitbucket+101 - Git https://www.atlassian.com/git?utm_source=cac-bitbucket-1&utm_medium=banner&utm_content=visual-git-guides&utm_campaign=git-tutorial - EGit (Git with Eclipse) http://www.vogella.com/tutorials/eclipsegit/article.html http://wiki.eclipse.org/egit/user_guide Easy & Quick Code Sharing - If you don t want to bother having version control http://www.smashingapps.com/2011/05/25/ten-best-collaborative-sites-for-quick-code-sharing.html