Map, List, Stack, Queue, Set - University of Washington
Map, List, Stack, Queue, Set
Special thanks to Scott Shawcroft, Ryan Tucker, and Paul Beck for their work on these slides. Except where otherwise noted, this work is licensed under:
Stack
? Information found here:
? stdtypes.html
? Really easy! ? Use lists to simulate a stack ? .append(value) in order to "push" onto the
stack ? .pop() in order to `pop' off the stack. ? Check this example out!
2
Queue
? Really easy too!!!! ? Use lists to simulate a queue ? .insert(0, value) in order to `add' to the
queue. ? .pop() in order to `remove' off from the
queue. ? Why does this work? What do insert and pop
really do?
3
Queue
? Ok... this is dumb... and inefficient. ? Using lists, we get O(N), but..... ? from collections import deque ? queue = deque([`blah', `blah', `blah']) ? Use append() to `add' to the queue ? Use popleft() to `remove' from the queue ? This works in O(1)!
? Sweeeeeeeeet.
4
Dictionary
? Equivalent to Java's Map.
? Stores keys and values.
? Empty dictionary is defined by:
? m = {}
? Pre-populated dictionary: (Map)
? (mapping names to SCII division...)
? m2 = { `jordan' : `master', `roy' : `bronze', `marty' : `bronze' }
? Add to dictionary:
? m2[ `IMMVP' ] = `master'
? Retrieve from dictionary
? m2[`jordan']
# `master'
? Example!!
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- lecture 14 nested lists tuples and dictionaries
- topic 6 lists sets tuples dictionaries
- data structures in python grapenthin
- map list stack queue set university of washington
- writing python 2 3 compatible code
- how to get keys of python dictionary as list
- python 3 beginner s reference cheat sheet http www
- create a list of keys values key value tuples from a
- dictionaries
- dictionaries cs111
Related searches
- university of washington hr jobs
- university of washington jobs listing
- university of washington human resources
- university of washington human resources dept
- university of washington baseball roster
- university of washington product management
- university of washington online mba
- university of washington printable map
- university of washington opioid taper
- university of washington opioid calculator
- university of washington program management
- university of washington graduate programs