Data Structures continued
Tyler Moore
CSE 3353, SMU, Dallas, TX
February 7, 2013
Portions of these slides have been adapted from the slides written by Prof. Steven Skiena at SUNY Stony Brook, author
- f Algorithm Design Manual. For more information see http://www.cs.sunysb.edu/~skiena/
POTD: Attempt parts (a) and (b) of Q1
Before class on Thursday, please attempt problem Q1 (a) and (b) You won’t turn anything in on Thursday, but I want to know if you are able to successfully code this first part of the problem It’s OK if you can’t get a working solution. In this case, bring me your errors! If you get stuck on an error, I want to know about it, so we can discuss with the class. There is a VERY good chance some of your classmates are experiencing similar trouble.
2 / 29
Variables in Python
Better thought of as names or identifiers attached to an object. A nice explanation: http://python.net/~goodger/projects/pycon/2007/ idiomatic/handout.html#other-languages-have-variables
3 / 29
Key distinction: mutable vs. immutable objects
Immutable: objects whose value cannot change
1
Tuples (makes sense)
2
Booleans (surprise?)
3
Numbers (surprise?)
4
Strings (surprise?)
Mutable: objects whose value can change
1
Dictionaries
2
Lists
3
User-defined objects (unless defined as immutable)
This distinction matters because it explains seemingly contradictory behavior
4 / 29