Skip to content

Instantly share code, notes, and snippets.

@lessandro
Last active December 16, 2015 10:49
Show Gist options
  • Save lessandro/5423327 to your computer and use it in GitHub Desktop.
Save lessandro/5423327 to your computer and use it in GitHub Desktop.
# PRAGGIT QUIZ # 123: CALCULATE THE TIME COMPLEXITY OF THESE FUNCTIONS
def f(n):
ls = []
for i in xrange(n):
ls.append(i)
# (1) AVERAGE CASE:
# (2) WORST CASE:
# (3) AVERAGE CASE FOR LINE 6:
# (4) WORST CASE FOR LINE 6:
def g(n):
d = {}
for i in xrange(n):
d[random.random()] = 1
# (5) AVERAGE CASE:
# (6) WORST CASE:
# (7) AVERAGE CASE FOR LINE 17:
# (8) WORST CASE FOR LINE 17:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment