Assignment
Assignment
CHOOSE1Solved
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
Q2. CHOOSE4Solved
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
What does it mean when we say that an algorithm X is asymptotically more efficient than Y?
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
An algorithm consists of two independent piece of code, having complexities f(n) and g(n)
respectively. What would be the complexity of the complete algorithm
Q4. LOOP_CMPL2Solved
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
int i, j, k = 0;
for (i = n/2; i <= n; i++) {
for (j = 2; j <= n; j = j * 2) {
k = k + n/2;
}
}
Choose the correct answer from below:
Θ(n)
Θ(nLogn)
Θ(n^2)
Θ(n^2 / Logn)
Θ(n^2Logn)
Q5. NESTED_CMPLSolved
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
What is the time, space complexity of following code :
C++
Java
Python
int a = 0, b = 0;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
a = a + j;
}
}
for (k = 0; k < N; k++) {
b = b + k;
}
int a = 0, b = 0;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
a = a + j;
}
}
for (k = 0; k < N; k++) {
b = b + k;
}
a = 0
b = 0
for i in range(N):
for j in range(N):
a = a + j
for k in range(N):
b = b + k
Choose the correct answer from below:
O(N * N) time, O(1) space
O(N) time, O(N) space
O(N) time, O(N) space
O(N * N) time, O(N) space
O(N * N * N) time, O(1) space
Q6. LOOP_CMPLSolved
Stuck somewhere?
Ask for help from a TA and get it resolved.
Get help from TA.
What is the time, space complexity of following code :
int a = 0, b = 0;
for (i = 0; i < N; i++) {
a = a + rand();
}
for (j = 0; j < M; j++) {
b = b + rand();
}