[SOLVED] Express the complexity of these functions using the big-O notation

25.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

 

  1. Express the complexity of these functions using the big-O notation: a. T(n) = 2n2 + 3n3
  2. T(n) = 5 + n

 

  1. Use the definition of big-O to show that T(n) = 5 + n3 O(n3)

 

  1. Write down the running time function of the following Python function. Then describe it in terms of O and

 

def h(a_list)

n = len(a_list) i = n-1

sum = 0

while i>=0 do:

i = i 1 j = 0

while j<n do:

j = j*2

sum = sum + a_list[i] + a_list[j]

 

  1. Write down the running time function of the following Python function. Then describe it in terms of O and .

 

def g(a_list)

n = len(a_list) sum = 0

for i in range(n):

for j in range(n*n):

for k in range(j):

sum = i + j + a_list[i]

 

  1. Write down the running time function of the following Python function. Then describe it in terms of O and . (Assume that the running time of function foo is n*log(n).)

 

def bar(a_list)

n = len(a_list) sum = 0

for i in range(n):

sum = sum + a_list[i] value = 1

for j in range(n*n):

value = value * j

foo(sum, value)

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.