

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
Not enough gems
Cost: 6 gems
1: Big O Notation
incomplete
2: O(n) - Order 'n'
incomplete
3: O(n^2) - Order 'N Squared'
incomplete
4: N^2 Quiz
incomplete
5: O(nm)
incomplete
6: Constants Don't Matter
incomplete
7: Constants Quiz
incomplete
8: Order 1
incomplete
9: Order Log N
incomplete
10: Name Count
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
O(1) means that no matter the size of the input, there is no growth in the runtime of the algorithm. This is also referred to as a "constant time" algorithm.
In Python, a dictionary offers the ability to look items up by key, which is an operation that is independent of the size of the dictionary:
# this is a constant time lookup
org = organizations[org_id]
Dictionary lookups are O(1). Which is one of the reasons dictionaries and dictionary-equivalents in other languages are used all over the place.
We need to be able to search our LockedIn user base more quickly! Our users are complaining that the search bar is painfully slow. The starter code searches every entry, which takes a very long time for large inputs.
The find_last_name function takes
names_dict: a dictionary of first_name -> last_name.first_name: a string.If first_name is a key in the dictionary, find_last_name returns the associated last name. If the key is not found, it returns None.
Write the function so that it runs quickly! It should be O(1).