COL100 Major
COL100 Major
Student
Tanvi Mathur
Total Points
49 / 85.34 pts
Question 1
1 10 / 10 pts
− 0 pts Correct
− 5 pts Incorrect
− 5 pts Incorrect/Unattempted
+ 10 pts correct
+ 0.5 pts Correct base case of recursion, (method 1)A[0] or (method 2)A[len(A)-1]
+ 2 pts Correct derivation for the time complexity of recursion (method 1)T(n) = T(n-1) +logn or (method 2)T(n) =
T(n-1) + c
+ 0.5 pts Correct arguments for iterative case loop (1,n+1) or (1,len(A))
Question 3
3 4 / 5 pts
+ 5 pts Correct Answer
+ 1 pt Partially Correct Answer : computed the division correctly but there are minor errors in the code
+ 1 pt Partially Correct Answer : computed the reciprocal correctly but there are minor errors in the code
− 0 pts Correct
− 1.5 pts intialization condition inside i loop (eg sum=0) is not correct
Question 5
5 7 / 10 pts
− 0 pts Correct
− 10 pts Incorrect / NA
Question 6
6 0 / 5 pts
− 0 pts Correct answer
Question 8
8 0 / 10 pts
+ 1.33 pts For part 1
The two loop blanks - 1.33 mark
All other blanks - 1.33 mark each
+ 8 pts For part 1: Completely correct. All the 6 blanks are correct.
+ 0 pts Part 2: Considered all the paths that contribute towards the minimum cost for reaching the cells at the last
row.
+ 2 pts (Prime case) Returned Value is always correct for any natural number input i.e.
For all integer I, in range (0, m),
m is not divisible by I i.e. m % I > 0
+ 2 pts (Non-Prime case) Returned Value is always correct for any natural number input i.e.
For any integer K, in range (m, n],
there exists an integer, I in (0, K),
s.t. K is divisible by I i.e. K % I = 0
I have tried to prove that numbers greater than m//2 can never divide m. So if 2<i<m//2
never divided m it is prime.
def min(L) :
m = L[0]
for i in range( 1, len(L) ):
.# Loop invariant : m <= L_x, for all x<i
if L[i] < m : m = L[i]
.# Loop invariant : m <= L_x for all x<=i
return m
Loop invariant 2 : m ≤ Li
• m ≤ Li ?
• Li< m → m = Li
Question 11
11 5 / 5 pts
+ 1 pt Partially correct return statement in the line function as a, b, c are not passed as list
+ 1 pt Partially correct return statement in the plane function as a,b,c,d are not passed as list
+ 1 pt Correct return statement in the line and plane function where a,b,c,d are passed as a list:
Line function:
return linear([a,b,c])
Plane function:
return linear([a,b,c,d])
Question 12
bonus 1 / 5.34 pts
+ 5.34 pts Correct
+ 2.34 pts In worst case time complexity, the sub problems chosen will always be of length 2 ∗ n/3
+ 2 pts Solving the recurrence relation we get the worst case time complexity as O(log 3 n).
2
+ 1 pt As O(log 3 n)
log2 n
= O( log 3 ) = O(logn)
2
2
2
You are supposed to divide the array into two unequal parts not into three parts
1