May 20
... start recording.
Looking ahead :
- Monday is our last class
- It would be great to have as many of you do a brief presentation of your final project - share your screen, do a demo, explain what you did
- Due date for the final version (code,docs,paper) is also Monday ... but up through the last day of classes (Thu) is OK.
- Any questions about the final project and what's expected?
- Today ...
- Part 1 : overview of what we've covered this semester.
- Part 2 : time for an SEPC conversation (without me)
overview
"Algorithms" and "Data Structures"
algorithm
What is an "algorithm" ? A recipe for solving a math-ish problem, often of a certain size N
Big ideas :
- search : moving among "states" of the problem
- brute force : try every possible problem state
- divide and conquer : combine answer from same problem on half (usually) original
- greedy : move directly towards the solution (doesn't always give right answer)
- recursion : call the same function on a smaller part of the problem
- looping : the flip-side of recursion; often you can choose to do either
- dynamic programming : badly-named variation of divide-and-conquer; build up solution from smaller solutions in some order
- analysis of algorithms
- time complexity - O() notation
- O(1) : constant time
- O( log(n) ) : fast
- O( \( n^c \) ) for some constant c : polynomial ... not too bad
- O( \( 2^n \) ) : exponential ... bad (brute force over all true/false for n variables)
- O( n! ) : factorial ... really bad (brute force over all permutations)
- space complexity - how much memory - same sort of ideas, but we didn't really cover
- often there's a trade-off choice between optimizing for time or for space
data structure
What is a "data structure" ? A type of container to organize data, with an API of methods, and various O() behaviors
Algorithms use various data structures in their implementations .
For each of these, remind ourselves of the API and what they're used for.
- indexed array: stuff[i]
- linked list: a -> b -> c
- queue & stack
- hash table = dictionary
- priority queue = heap (well, often implemented as a heap anyway)
- tree : (a (b (c d) (e (f g))) ; nodes with children
- graph : vertices with neighbors ... in several flavors
We made the distinction between an "abstract data type" and an "implementation of an ADT".
python vs C
We used two languages this term, to at least some extent.
Pros and cons of each ?
problems
And we looked at a number of specific (and classic) problems,
as illustrations of the big ideas. In some cases, we worked
through several algorithms to solve the same problem.
- sorting
- O( n! ) : bogosort
- O( n**2 ) : bubble sort , for example
- O( n * log(n) ) : quicksort , for example
- O( n ) : bucket sort ... no comparisons ; only for limited types of data
- tree search
- (depth or breadth) using (stack or queue)
- recursive backtrack
- maze generation & solution
- peg solitarire solution
- graph
- shortest path : Djikstra's , Floyd
- min spanning tree : Prim's , Kruskal's
- ... using dat structures like (priority queue + hash table)
- game search
- min/max variation of tree search
- variations : alpha-beta pruning ; iterative deepening
- tic-tac-toe example
... and of course your own various final projects. ;)
life, the universe, and everything
Discussion of topics over the last week or so :
- complexity theory ... P vs NP
- finite state machines, regular expressions
- turing machines and what they can and can't do
- philosophy of mind ... is thinking computation?
coming attractions
CS courses for next year as currently scheduled :
Fall
- Coding Workshop (2 credits ; optional 3rd for individual project)
- Structure & Interpretation of Computer Programs
- Internet Seminar - various topics
- Tim : Python Programming
Spring
- Intro CS
- Algorithms
- Plan Programming Projects
... and we're planning on searching again for another CS faculty.
SEPC
Over to you ...