Lecture 30(Monday) - CSC 165 more asymptotics Course Notes...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC 165 more asymptotics Course Notes chapter 5 & 6 Danny Heap [email protected] http://www.cdf.toronto.edu/ f heap/165/F10/ slide 1 bounding a sort def IS(A) : """ IS(A) sorts the elements of A in non-decreasing order """ 1. i = 1 2. while i < len(A) : 3. t = A[i] 4. j = i 5. while j > 0 and A[j-1] > t : 6. A[j] = A[j-1] # shift up 7. j = j-1 8. A[j] = t 9. i = i+1 I want to prove that W IS 2 O ( n 2 ). slide 12 scratch slide 13 computer mis-statements You may have encountered unsatisfying results in python: >>> x = 1/10.0 >>> 0.3 == (x + x + x) >>> 0.3 - (x + x + x) >>> b = 1.0 >>> s = 1.0e-16 >>> s + s + s + s + s + s + s + s + s + s + b >>> b + s + s + s + s + s + s + s + s + s + s >>> import math >>> math.pi >>> math.e >>> bf = 2.0 >>> for i in range(10) : ... bf *= bf ... print bf ... slide 14 how numbers are represented There are other ways to represent numbers: do arithmetic on ratios (scheme, lisp) but there are always costs If you x the cost of arithmetic operations, you x the size of numbers...
View Full Document

{[ snackBarMessage ]}

Page1 / 8

Lecture 30(Monday) - CSC 165 more asymptotics Course Notes...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online