Download presentation
Presentation is loading. Please wait.
Published byHilde Anne-Marie Larssen Modified over 6 years ago
1
EN.540.635 - Software Carpentry
Python – A Crash Course Big O Notation
2
Functions! Y = x Y = log10(x)
3
Functions! Y = x^2 Y = x * log10(x)
4
Functions! Y = 2^x
5
How does a problem scale?
Useful to define some parameter describing how something scales O notation – Upper bound Ω notation – Lower bound Θ notation – Exactly bound We ignore constants Question: What does the Big O notation tell us?
6
Examples Fit Functions 𝑦=4 ∗𝑥 𝑦= ∗𝑥 𝑦=4 ∗ log 10 4𝑥 𝑦= 𝑥 𝑦=x ∗ log 10 x+4 +x Big O Notation 𝑂(𝑁) 𝑂 log 𝑁 𝑂 𝑁 4 𝑂 𝑁𝑙𝑜𝑔 𝑁 For more information, you can look at complexities here.
7
Sorting How can we sort the following array: Insertion 𝑂 𝑁 2
Merge 𝑂 𝑁𝑙𝑜𝑔 𝑁 Quick 𝑂 𝑁 2 Bubble 𝑂 𝑁 2 Radix 𝑂 𝑤𝑁 →O N , O Nlog N , worse More 5 38 23 9 27 1
8
Group Project - Lazor
9
Group Project - Lazor Block Types
10
Example Input File Next Few Slides
Group Project - Lazor Example Input File Next Few Slides
11
Group Project - Lazor # This is a comment
# This example is for mad 1 in Lazor # x = no block allowed # o = blocks allowed # A = fixed reflect block # B = fixed opaque block # C = fixed refract block # Grid will start at top left being 0, 0 # Step size is by half blocks # Thus, this leads to even numbers indicating # the rows/columns between blocks, and odd numbers # intersecting blocks.
12
Group Project - Lazor GRID START o o o o GRID STOP
# Here we specify that we have 2 reflect blocks # and 1 refract block A 2 C 1 # Now we specify that we have one lazer # x, y, vx, vy # NOTE! because 0, 0 is the top left, our axis # are as follows:
13
Group Project - Lazor # __________\ +x # | / # | # \|/ +y # L 2 7 1 -1
# | / # | # \|/ +y # L # Here we have the points that we need the lazers to intersect P 3 0 P 4 3 P 2 5 P 4 7
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.