12
Problem Solving with Algorithms and Data Structures Bruce Tsai

Problem Solving with Algorithms and Data Structures

Embed Size (px)

DESCRIPTION

Slides for http://interactivepython.org/runestone/static/pythonds/index.html

Citation preview

Page 1: Problem Solving with Algorithms and Data Structures

Problem Solving with Algorithms and Data

Structures

Bruce Tsai

Page 2: Problem Solving with Algorithms and Data Structures

Computer Science

• Algorithm

• Step-by-step procedure for calculations

• Data structure

• Way of organizing data

Page 3: Problem Solving with Algorithms and Data Structures

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

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

Python Data Type

• int

• float

• bool

• weak type

• dynamic strongly type

Page 6: Problem Solving with Algorithms and Data Structures

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

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

Python String

• “” or ‘’

• ordered

• duplicate elements

• immutable

• homogeneous

Page 9: Problem Solving with Algorithms and Data Structures

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

Exception

• Syntax error

• Logical error (runtime error)

• Exception

• prevent program to terminate from runtime error

Page 11: Problem Solving with Algorithms and Data Structures

Function

• Mathematical function

• Black box

• Input/Output

Page 12: Problem Solving with Algorithms and Data Structures

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/