DOC PREVIEW
MIT 6 001 - Order of Growth Problems

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:

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring, 2007 Recitation 4b, Wed. February 21 More Order of Growth Problems Dr. Kimberle Koile From 6.001 Fall 2005 Quiz 1: Suppose that you want to sort a list of elements. Here is a procedure for sorting: (define (find-best best todo compare) (if (null? todo) best (if (compare (car todo) best) (find-best (car todo) (cdr todo compare) (find-best best (cdr todo) compare)))) (define (remove elt todo same) (if (null? todo) '() (if (same elt (car todo)) (cdr todo) (cons (car todo) (remove elt (cdr todo) same))))) (define (sort data compare same) (let ((trial (find-best (car data) (cdr data) compare))) (let ((todo (remove trial data same))) (if (mull? todo) (list trial) (cons trial (sort todo compare same)))))) To sort a list of numbers called my-list in ascending order, for example, we could write: (sort my-list (lambda (x y) (< x y)) =) For each of the following questions choose the letter corresponding to the option that best describes the order of growth of the process in question. A: constant B: linear C: exponential D: quadratic E: logarithmic F: something elseWhat is the order of growth in time for find-best? What is the order of growth in space for find-best? What is the order of growth in time for remove? What is the order of growth in space for remove? What is the order of growth in time for sort? What is the order of growth in space for


View Full Document

MIT 6 001 - Order of Growth Problems

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 Order of Growth Problems
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 Order of Growth Problems 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 Order of Growth Problems 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?