DOC PREVIEW
MIT 6 001 - Orders of Growth

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

STUDENT NAME: 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.001—Structure and Interpretation of Computer ProgramsFall 2004Recitation 4Orders of GrowthDefinitionsTheta (Θ) notation:f(n) = Θ(g(n)) → k1· g(n) ≤ f (n) ≤ k2· g(n), for n > n0Big-O notation:f(n) = O(g(n)) → f (n) ≤ k · g(n), for n > n0Adversarial approach: For you to show that f (n) = Θ(g(n)), you pick k1, k2, and n0, then I (theadversary) try to pick an n which doesn’t satisfy k1· g(n) ≤ f (n) ≤ k2· g(n).ImplicationsIgnore constants. Ignore lower order terms. For a sum, take the larger term. For a product,multiply the two terms. Orders of growth are concerned with how the effort scales up as the sizeof the problem increases, rather than an exact measure of the cost.Typical Orders of Growth• Θ(1) - Constant growth. Simple, non-looping, non-decomposable operations have constantgrowth.• Θ(log n) - Logarithmic growth. At each iteration, the problem size is scaled down by aconstant amount: (call-again (/ n c)).• Θ(n) - Linear growth. At each iteration, the problem size is decremented by a constantamount: (call-again (- n c)).• Θ(n log n) - Nifty growth. Nice recursive solution to normally Θ(n2) problem.• Θ(n2) - Quadratic growth. Computing correspondence between a set of n things, or doingsomething of cost n to all n things both result in quadratic growth.• Θ(2n) - Exponential growth. Really bad. Searching all possibilities usually results in expo-nential growth.What’s n?Order of growth is always in terms of the size of the problem. Without stating what the problemis, and what is considered primitive (what is being counted as a “unit of work” or “unit of space”),the order of growth doesn’t have any meaning.STUDENT NAME: 2Problems1. Assume you have a procedure (divisible? n x) which returns #t if n is divisible by x. Itruns in O(n) time and O(1) space. Write a procedure prime? which takes a number andreturns #t if it’s prime and #f otherwise. You’ll want to use a helper procedure.Running time?


View Full Document

MIT 6 001 - Orders of Growth

Documents in this Course
Quiz 1

Quiz 1

6 pages

Databases

Databases

12 pages

rec20

rec20

2 pages

Quiz II

Quiz II

15 pages

Streams

Streams

5 pages

Load more
Download Orders of Growth
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Orders of Growth and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Orders of Growth 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?