WorksheetsDAA Unit - I
Total questions: 59
Worksheet time: 16mins
Which of the following is incorrect?
Algorithms can be represented:
as pseudo codes
as syntax
as programs
as flowcharts
What is the Formula for Big O
F(n) ≤ c × g(n)
F(n) ≥ c × g(n)
c1 × g(n) ) ≤ F(n) ≤ c2 × g(n)
F(n)= c × g(n)
Analysis of algorithm based on
Time & Space Complexity
Simplicity of an Algorithm
Generality of an Algorithm
All the mentioned
Decision making of an algorithm based on
Computational Device
Exact or approximate method
Data Structures & Algorithm Strategies
All the mentioned
In which algorithm problems are divided into several subproblems
Divide and Conquer
Dynamic Programming
Branch and Bound
Greedy Algorithm
What is Co represent in the asymptotic notation
Starting point
Break point
End point
None of the mentioned
The time complexity of the solution tower of hanoi problem using recursion is _________
O(n2)
O(2n)
O(n log n)
O(n)
The Time complexity of
ALGORITHM MaxElement(A[0..n − 1])
//Determines the value of the largest element in a given array
//Input: An array A[0..n − 1] of real numbers
//Output: The value of the largest element in A
maxval ← A[0]
for i ← 1 to n − 1 do
if A[i] > maxval
maxval ← A[i]
return maxval
n-1
n
2n
n+1
The Time complexity of
Algorithm sum(1,n)
Problem Description: The algorithm is for finding the sum of n numbers
Input: 1 to n numbers
Output: the sum of n numbers
result <-- 0
for i <-- 1 to n do
result <-- result + i
return result
n3
n2
n
2n
The Time complexity of
Algorithm Matrix_addition(A,B,n)
Problem Description: The algorithm us for computing Addition of two matrix's
Input: The two matrix A,B and order of them as n.
Output: The Addition result will be in matrix c
for i <-- 1 to n do
for j <-- 1 to n do
C[i,j] <-- 0
for k<-- 1 to n do
C[i,j] <-- A[i,j] + B[i,j]
n3
n2
n
2n
Minimum number of moves required to solve a tower of hanoi problem with n disks is __________
2n
2n-1
n2
n2-1
The Time complexity of
Algorithm even_odd(val)
Problem Description: The algorithm test whether given number is even or odd
Input: The number to be tested
Output: Appropriate messages indicating even or odd
if(val%2=0) then
write(“Given number is even”)
else
write(“Given number is odd”)
2n
2n-1
n2
1
The space complexity of
Algorithm sum(1,n)
Problem Description: The algorithm is for finding the sum of n numbers
Input: 1 to n numbers
Output: the sum of n numbers
result <-- 0
for i <-- 1 to n do
result <-- result +i
return result
1+n
2+n
3+n
n
The space complexity of
Algorithm even_odd(val)
Problem Description: The algorithm test whether given number is even or odd
Input: The number to be tested
Output: Appropriate messages indicating even or odd
if(val%2=0) then
write(“Given number is even”)
else
write(“Given number is odd”)
1
n
2n
n2
The space complexity of
Algorithm Matrix_addition(A,B,n)
Problem Description: The algorithm us for computing Addition of two matrix's
Input: The two matrix A,B and order of them as n.
Output: The Addition result will be in matrix c
for i <-- 1 to n do
for j <-- 1 to n do
C[i,j] <-- 0
for k <-- 1 to n do
C[i,j] <-- A[i,j] + B[i,j]
1+n
2+n
3+n
n
t(n) = 4n+ 2 and g(n) = n2 using big oh notation what is no
5
4
3
2
t(n) = n2 and g(n) = 3n+ 2 using omega notation what is no
5
4
3
2
What is the time complexity for the following recurrence relation
T(n) = 4T(n/2) + n
O(n2)
O(n)
O(nlogn)
O(logn)
What is the time complexity for the following recurrence relation
T(n) = 2T(n/2) + n
O(n2)
O(n)
O(nlogn)
O(logn)
The graph represent which notation
Big oh
Omega
Theta
Sigma
The graph represent which notation
Big oh
Omega
Theta
Sigma
The graph represent which notation
Big oh
Omega
Theta
Sigma
