write the big O complexity of the two functions. show complete solution esp. in noting the runtime of the instructions in within the loop

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
Question

write the big O complexity of the two functions. show complete solution esp. in noting the runtime of the instructions in within the loop

def zim(a, b):
tmp = 1
for i in range(1, b+1):
if (a%i + b%i) == 0:
tmp = i
return tmp
def zam(a, b):
while b > 0:
a, b = b, a % b
return a
Transcribed Image Text:def zim(a, b): tmp = 1 for i in range(1, b+1): if (a%i + b%i) == 0: tmp = i return tmp def zam(a, b): while b > 0: a, b = b, a % b return a
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole