Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 : 0 7 C Back HomeWork 1 . pdf For each of the following functions, do the following: Calculate T ( n ) ,

6:07 C
Back HomeWork1.pdf
For each of the following functions, do the following:
Calculate T(n), making sure not to discard constants or low-order terms yet (you may or may not count the counting variable in a for loop)
Given what you think is the Big-O performance for the function
Prove that your proposed Big-O for the function is correct (make sure to show your work; do not just provide values for c and n0)
(1)
def fun1(n) :
x=0
for iin range (2,n2) :
,x=x**2
return x
(2)
def fun2(n):
x=0
for i in range(n :
for j in range (n) :
for k in range (1,n)
x=x+1
return x
(3)
def fun3(n) :
x=0
i=2**n
while i1:
x=x-i
i=i-1
return x
1
(4)
def fun4(n):
x=n
for i in range (n**n) :
x=x+2
return x
(5)
# lst is a list of integers
def fun5(1st):
x=0
for y in lst:
x=x+y
return x
Problem 2(10 points each)
Suppose an algorithm solves a problem of input size n in at most the number of steps listed for each T(n) given below. Calculate the Big-(not just Big-O) for each T(n). Show your work, including values for c and n0.
(1)T(n)=10
(2)T(n)=2n3+1
(3)T(n)=n4+2n2+nlogn
(4)T(n)=log(52n)
(5)T(n)=3n2logn
(1)
1
Dashboard
Calendar
To Do Notifications
Inbox
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions