Uploaded by manthanthakkar98

Assignment 1-2024

advertisement
Assignment 1
Full name:
CSU ID:
Question 1 (4points). For the following functions, please indicate that the first function has the
lower, same, or higher order of growth than the second function (please give the procedure,
selecting the right option but without procedure will only receive partial credit)
!
a. (2ponits) √𝑛 and ln 𝑛 (a is a bounded positive integer)
Choose: lower/same/higher
#
Hint: (𝑛! )′ = π‘Žπ‘›!"# , (ln 𝑛)′ = $
b. (2points) 𝑛%.''' log ( 𝑛 and 10000n
Choose: lower/same/higher
Question 2. (2points) Choose the correct answer (please give the procedure, selecting the right
option but without procedure will only receive partial credit)
a. log ( 𝑛 ∈ 𝑂(log ) 𝑛) b. log ( 𝑛 ∈ Ω(log ) 𝑛)
𝑐. log ( 𝑛 ∈ Θ(log ) 𝑛) d. all of the above
Question 3 (3points)
1οΌ‰what’s the problem size and what’s the basic operation (1point)
2) Using O(n) notation to analyze the time complexity (please give the procedure, if you can’t
conclude the closed-form formula for O(n) but provide critical steps, we will consider to give
you partial credit) (2points)
Hint: if a closed-form formula is difficult to get, think about using an equality for a lower/upper
bound
count = 0
i=N
while i > 0:
for j in range(0, i):
count += 1
i = int(i/2)
Questions 4 (3 points)
1οΌ‰write down the recurrence and use backward substitution for n=k (1 points)
2) Use O notation to conclude its complexity (2 points)
Function func(A, n)
#A is an array of n integers
If n <= 1 return A[n]
x = func(A, ⌊𝑛/4⌋)
for i=1 to n do
A[i]=A[n-i]-A[i]
end
x=x+func(A, ⌊𝑛/4⌋))
return x
Download