15
DSAN 5500: Data Structures, Objects, and Algorithms in Python
Thursday, April 3, 2025
Today’s Planned Schedule:
Start | End | Topic | |
---|---|---|---|
Lecture | 6:30pm | 6:45pm | Final Projects → |
6:45pm | 7:00pm | HW4 on Jetstream → | |
7:00pm | 8:00pm | Beyond Embarrassingly Parallel → | |
Break! | 8:00pm | 8:10pm | |
8:10pm | 9:00pm | Data Mining in Parallel → |
Hofstadter’s Law (Paraphrase)
The pieces of your DSAN final project will take longer than you expect, even if you take Hofstadter’s Law into account
ThingContainer
.Linear | Logarithmic | Constant | ||
---|---|---|---|---|
LinkedList \(O(n)\) |
\(\rightarrow\) | BST \(O(\log_2(n))\) |
\(\rightarrow\) | HashTable \(O(1 + \varepsilon)\) |
Linear | Logarithmic | Constant | ||
---|---|---|---|---|
Insertion-Sort \(O(n^2)\) |
\(\rightarrow\) | Merge-Sort \(O(n\log_2(n))\) |
\(\rightarrow\) | ??? |
Multithreading | Asynchronous Execution | |
---|---|---|
Unconsciously (you do it already, “naturally”) |
Focus on one speaker within a loud room, with tons of other conversations entering your ears | Put something in oven, set alarm, go do something else, take out of oven once alarm goes off |
Consciously (you can do it with effort/practice) |
Pat head (up and down) and rub stomach (circular motion) “simultaneously” | Throw a ball in the air, clap 3 times, catch ball |
threading
multiprocessing
asyncio
find_prime_factors()
task…@task
annotation!map()
and reduce()
are “meta-functions”: functions that take other functions as inputslambda
):When a program doesn’t work, each function is an interface point where you can check that the data are correct. You can look at the intermediate inputs and outputs to quickly isolate the function that’s responsible for a bug.
(from Python’s “Functional Programming HowTo”)
# Convert to lowercase
Easy case: found typo in punctuation removal code. Fix the error, add comment like # Remove punctuation
Rule 1 of FP: transform these comments into function names
Hard case: Something in load_text()
modifies a variable that later on breaks remove_punct()
(Called a side-effect)
Rule 2 of FP: NO SIDE-EFFECTS!
remove_punct()
!!! 😎 ⏱️ = 💰From Leskovec, Rajaraman, and Ullman (2014)
From Leskovec, Rajaraman, and Ullman (2014), which is (legally) free online!
From Cornell Virtual Workshop, “Understanding GPU Architecture”
DSAN 5500 Week 12: Final Projects, Map-Reduce