Python: Big O a) What is the big-oh of Algorithm 0? Algorithm 0: result = 0 for i in range XXXXXXXXXX): result = result + i b) What is the big-oh of Algorithm 1? Algorithm 1: result = 0 for i in...


Python: Big O


a) What is the big-oh of Algorithm 0?
Algorithm 0:
    result = 0
    for i in range(10000000):
        result = result + i




b) What is the big-oh of Algorithm 1?
Algorithm 1:
    result = 0
    for i in range(n):
        result = result + I
    # end for



c) What is the big-oh of Algorithm 2?
Algorithm 2:
    result = 0
    for r in range(n):
        c = n
        while c > 1:
            result = result + c
            c = c // 2
        # end while
    # end for




d) What is the big-oh of Algorithm 3?
Algorithm 3:
    result = 0
    for r in range(n):
        for c in range(n):
            result = result + c
        # end for
    # end for




e) What is the big-oh of Algorithm 4?
Algorithm 4:
    result = 0
    for r in range(n):
        for c in range(n):
            for d in range(n*n*n):
                result = result + d
            # end for
        # end for
    # end for




f) What is the big-oh of Algorithm 5?
Algorithm 5:
    result = 0
    i = 0
    while i <>
        result = result + I
        i += 1
    # end while


a) What is the big-oh of Algorithm 0?<br>Algorithm 0:<br>result = 0<br>for i in range (10000000):<br>result = result + i<br>b) What is the big-oh of Algorithm 1?<br>Algorithm l:<br>result = 0<br>for i in range (n) :<br>result = result + i<br># end for<br>c) What is the big-oh of Algorithm 2?<br>Algorithm 2:<br>result = 0<br>for r in range (n) :<br>C = n<br>while c > 1:<br>result = result + c<br>C - c // 2<br># end while<br># end for<br>d) What is the big-oh of Algorithm 3?<br>Algorithm 3:<br>result = 0<br>for r in range (n) :<br>for c in range (n) :<br>result = result + c<br># end for<br># end for<br>e) What is the big-oh of Algorithm 4?<br>Algorithm 4:<br>result = 0<br>for r in range (n) :<br>for c in range (n) :<br>for d in range (n*n*n) :<br>result = result +d<br># end for<br># end for<br># end for<br>f) What is the big-oh of Algorithm 5?<br>Algorithm 5:<br>result = 0<br>i = 0<br>while i < 2**n:<br>result = result + i<br>i += 1<br># end while<br>

Extracted text: a) What is the big-oh of Algorithm 0? Algorithm 0: result = 0 for i in range (10000000): result = result + i b) What is the big-oh of Algorithm 1? Algorithm l: result = 0 for i in range (n) : result = result + i # end for c) What is the big-oh of Algorithm 2? Algorithm 2: result = 0 for r in range (n) : C = n while c > 1: result = result + c C - c // 2 # end while # end for d) What is the big-oh of Algorithm 3? Algorithm 3: result = 0 for r in range (n) : for c in range (n) : result = result + c # end for # end for e) What is the big-oh of Algorithm 4? Algorithm 4: result = 0 for r in range (n) : for c in range (n) : for d in range (n*n*n) : result = result +d # end for # end for # end for f) What is the big-oh of Algorithm 5? Algorithm 5: result = 0 i = 0 while i < 2**n: result = result + i i += 1 # end while 2**n:="" result="result" +="" i="" i="" +="1" #="" end="">
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here