

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Introduction to Data Structures
incomplete
2: What Are Data Structures?
incomplete
3: Lists
incomplete
4: Lists Quiz
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Okay, we know what lists are, but from a data structures and algorithms perspective, what are they good for? Let's break it down by operation:
Append: Appending an element to the end of a list, e.g. cars.append("ford") is (on average) O(1). We go directly to the end and add the element.
Index: Accessing an element by index, e.g. cars[2] is O(1). We go directly to the index and return the element.
Delete: Removing an element from the middle of a list, e.g. cars.pop(2) is O(n). We have to shift all the elements after the deleted element down one index.
Search: Searching for an element in a list, e.g. cars.index("ford") is O(n). We have to iterate over the list until we find the element.
In other words, lists start to struggle in two primary areas:
When you need to frequently delete elements from the middle of the list
When you need to frequently search for specific elements in the entire list
We need to display a user's last job title on their profile.
Implement the last_work_experience function. It takes a list of our user's work history (strings) and returns the last place they worked.
Assume the list is ordered from oldest to most recent.
If the list is empty, return None.