List and Dictionary Efficiency Preparation
Overview
When storing data, the two main structures that you’ve seen so far are lists and dictionaries. We’ve mentioned previously how lists are slow for finding items and dictionaries are fast. While we won’t get into exactly how dictionaries are so fast, we will look today at what algorithm analysis can tell us about common list operations.
Basic Learning Objectives
Before class, you should be able to:
- Compare lists and dictionaries efficiency for their common operations
- Identify which tasks lists or dictionaries are more efficient at
Advanced Learning Objectives
After class, you should be able to:
- Explain why lists in Python have the time efficiency that they do for indexing and
contains
- Evaluate when you should use a list versus a dictionary to solve a problem based on the time efficiency
Resources
Read/watch the following and complete the embedded checks:
- Runestone 2.5-2.7