problem solving with algorithms and data structures
DESCRIPTION
Slides for http://interactivepython.org/runestone/static/pythonds/index.htmlTRANSCRIPT
![Page 1: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/1.jpg)
Problem Solving with Algorithms and Data
Structures
Bruce Tsai
![Page 2: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/2.jpg)
Computer Science
• Algorithm
• Step-by-step procedure for calculations
• Data structure
• Way of organizing data
![Page 3: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/3.jpg)
Problem-solving• Human
• Time consuming
• Computer
• Efficiency
• Reuse
• Communication tool
• Program
• Method and Data
• Mathematical model
• Input/Output
![Page 4: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/4.jpg)
Sorting Example
50, 19, 1, 120, 6, 5, 999
1, 5, 6, 19, 50, 120, 999
![Page 5: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/5.jpg)
Python Data Type
• int
• float
• bool
• weak type
• dynamic strongly type
![Page 6: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/6.jpg)
Python Collection
• List []
• ordered
• duplicate elements
• mutable
• compound data
• Tuple ()
• ordered
• duplicate elements
• immutable
• heterogeneous data
![Page 7: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/7.jpg)
Python Collection
• Set {}, set()
• unordered
• no duplicate elements
• mutable
• heterogeneous data
• Dictionary { key: value}
• key-value pair
• no duplicate keys
• mutable
• heterogeneous data
![Page 8: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/8.jpg)
Python String
• “” or ‘’
• ordered
• duplicate elements
• immutable
• homogeneous
![Page 9: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/9.jpg)
Python Control Structure
• while
• execute code repeatedly based on given condition
• for
• allow code to repeatedly executed
• if, elif, else
• perform different computations depending on condition
![Page 10: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/10.jpg)
Exception
• Syntax error
• Logical error (runtime error)
• Exception
• prevent program to terminate from runtime error
![Page 11: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/11.jpg)
Function
• Mathematical function
• Black box
• Input/Output
![Page 12: Problem Solving with Algorithms and Data Structures](https://reader031.vdocuments.mx/reader031/viewer/2022020101/559e03a61a28ab1e6a8b479f/html5/thumbnails/12.jpg)
Reference
• http://interactivepython.org/runestone/static/pythonds/index.html
• https://docs.python.org/2/tutorial/
• http://zeroturnaround.com/rebellabs/there-is-more-to-code-quality-than-just-pretty-vs-ugly/