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

25.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

docx file icon New-Microsoft-Word-Document.docx (16 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

 

  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)

  • New-Microsoft-Word-Document.docx