Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DAA Unit - I

Total questions: 59

Worksheet time: 16mins

Name
Class
Date
1.
Which of the following problems can’t be solved using recursion?
a)
Factorial of a number
b)
Nth fibonacci number
c)
Length of a string
d)
Problems without base case
2.
 In recursion, the condition for which the function will stop calling itself is ____________
a)
Best case
b)
Worst case
c)
Base case
d)
There is no such condition
3.
 In general, which of the following methods isn’t used to find the factorial of a number?
a)
Recursion
b)
Iteration
c)
Dynamic programming
d)
Non iterative / recursive
4.
 Which of the following is not another name for GCD(Greatest Common Divisor)?
a)
LCM
b)
GCM
c)
GCF
d)
HCF
5.
Which of the following is also known as GCD?
a)
Highest Common Divisor
b)
Highest Common Multiple
c)
Highest Common Measure
d)
Lowest Common Multiple
6.
Which of the following option is wrong?
a)
Fibonacci number can be calculated by using Dynamic programming
b)
Fibonacci number can be calculated by using Recursion method
c)
Fibonacci number can be calculated by using Iteration method
d)
No method is defined to calculate Fibonacci number
7.
 Recursion is a method in which the solution of a problem depends on ____________
a)
Larger instances of different problems
b)
Larger instances of the same problem
c)
Smaller instances of the same problem
d)
Smaller instances of different problems
8.
Recursion is similar to which of the following?
a)
Switch Case
b)
Loop
c)
If-else
d)
if elif else
9.
Which of the following statements is true?
a)
Recursion is always better than iteration
b)
Recursion uses more memory compared to iteration
c)
Recursion uses less memory compared to iteration
d)
Iteration is always better and simpler than recursion
10.
Which of the following recursive formula can be used to find the factorial of a number?
a)
fact(n) = n * fact(n)
b)
fact(n) = n * fact(n+1)
c)
fact(n) = n * fact(n-1)
d)
fact(n) = n * fact(1)
11.
What is the GCD of 8 and 12?
a)
8
b)
12
c)
2
d)
4
12.
Which of the following methods can be used to find the largest and smallest element in an array?
a)
Recursion
b)
Iteration
c)
Both recursion and iteration
d)
No method is suitable
13.
What is the formula for the space complexity
a)
S(p) = C + Sp
b)
S(p) = Sp
c)
S(p) = C
d)
S(p) = C + n
14.
Which is the most efficient sorting algorithm
a)
Quick Sort
b)
Merge Sort
c)
Shell Sort
d)
Both Quick and Merge Sort
15.
This characteristic often draws the line between what is feasible and what is impossible.
a)
Performance
b)
System Evaluation
c)
Modularity
d)
Reliability
16.

Which of the following is incorrect?

Algorithms can be represented:

a)

as pseudo codes

b)

as syntax

c)

as programs

d)

as flowcharts

17.
 When an algorithm is written in the form of a programming language, it becomes a _________
a)
Flowchart
b)
Program
c)
Pseudo code
d)
Syntax
18.

What is the Formula for Big O

a)

F(n) ≤ c × g(n)

b)

F(n) ≥ c × g(n)

c)

c1 × g(n) ) ≤ F(n) ≤ c2 × g(n)

d)

F(n)= c × g(n)

19.
What is the Formula for Omega
a)
F(n) ≤ c × g(n)
b)
F(n) ≥ c × g(n)
c)
c1 × g(n) ) ≤ F(n) ≤ c2 × g(n)
d)
F(n)= c × g(n)
20.
What is the Formula for Theta
a)
F(n) ≤ c × g(n)
b)
F(n) ≥ c × g(n)
c)
c1 × g(n) ) ≤ F(n) ≤ c2 × g(n)
d)
F(n)= c × g(n)
21.
The Running time of Big O is
a)
Best Case
b)
Average Case
c)
Worst Case
d)
Medium Case
22.
The Running time of Omega is
a)
Best Case
b)
Average Case
c)
Worst Case
d)
Medium Case
23.
The Running time of Theta is
a)
Best Case
b)
Average Case
c)
Worst Case
d)
Medium Case
24.
The Big O Notation represent ___________________ bound
a)
Lower bound
b)
Upper Bound
c)
Both Lower and Upper Bound
d)
Middle bound
25.
The Omega Notation represent ___________________ bound
a)
Lower bound
b)
Upper Bound
c)
Both Lower and Upper Bound
d)
Middle bound
26.
The Theta Notation represent ___________________ bound
a)
Lower bound
b)
Upper Bound
c)
Both Lower and Upper Bound
d)
Middle bound
27.
If F1 (n) is order of g1 (n) and F2 (n) is order of g2 (n), then F1 (n) + F2 (n)
a)
O (max (g1 (n), g2 (n))
b)
O (min (g1 (n), g2 (n))
c)
O (g1 (n), g2 (n))
d)
O g1 (n) + O g2 (n)
28.
If there are two function f1(n) and f2(n) such that f1(n) = O(g1(n)) and f2(n) = O(g2(n)) then f1(n) * f2(n) is
a)
O(min(g1(n), g2(n))
b)
[O(g1(n))*O(g2(n))]
c)
O(g1(n), g2(n))
d)
Og1(n) + Og2(n)
29.
If f (n) = O (g (n)) and g (n) = O (h (n) then h (n) is
a)
O (t (n))
b)
O (g (n))
c)
O (h (n)
d)
O (f (n)).
30.
The Recurrence equation can be solved using
a)
Substitution Method
b)
Recurrence Tree Method
c)
Master Method
d)
All the Above
31.
Mathematical relation of tower of Hanoi is
a)
T (n) = 2T (n – 1) + 1
b)
T (n) = T (n – 1) + 1
c)
T (n) = 2T (n – 1)
d)
T (n) = 2T (n – 1) - 1
32.

Analysis of algorithm based on

a)

Time & Space Complexity

b)

Simplicity of an Algorithm

c)

Generality of an Algorithm

d)

All the mentioned

33.

Decision making of an algorithm based on

a)

Computational Device

b)

Exact or approximate method

c)

Data Structures & Algorithm Strategies

d)

All the mentioned

34.

In which algorithm problems are divided into several subproblems

a)

Divide and Conquer

b)

Dynamic Programming

c)

Branch and Bound

d)

Greedy Algorithm

35.
Time Space Tradeoff is
a)
Obtaining time complexity
b)
Obtaining space complexity
c)
Both time and space complexity
d)
None of the mentioned
36.
Order of the growth refers too
a)
Input size n
b)
Output size n
c)
Algorithm logic
d)
Basic operation
37.

What is Co represent in the asymptotic notation

a)

Starting point

b)

Break point

c)

End point

d)

None of the mentioned

38.
The optimal data structure used to solve Tower of Hanoi is _________
a)
Heap
b)
Priority queue
c)
Stack
d)
Tree
39.
What is the objective of tower of hanoi puzzle?
a)
To move all disks to some other rod by following rules
b)
To divide the disks equally among the three rods by following rules
c)
To move all disks to some other rod in random order
d)
To divide the disks equally among three rods in random order
40.
Which of the following is NOT a rule of tower of hanoi puzzle?
a)
No disk should be placed over a smaller disk
b)
Disk can only be moved if it is the uppermost disk of the stack
c)
No disk should be placed over a larger disk
d)
Only one disk can be moved at a time
41.

The time complexity of the solution tower of hanoi problem using recursion is _________

a)

O(n2)

b)

O(2n)

c)

O(n log n)

d)

O(n)

42.
Minimum time required to solve tower of hanoi puzzle with 4 disks assuming one move takes 2 seconds, will be __________
a)
30 seconds
b)
15 seconds
c)
16 seconds
d)
32 seconds
43.

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

a)

n-1

b)

n

c)

2n

d)

n+1

44.

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

a)

n3

b)

n2

c)

n

d)

2n

45.

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]

a)

n3

b)

n2

c)

n

d)

2n

46.

Minimum number of moves required to solve a tower of hanoi problem with n disks is __________

a)

2n

b)

2n-1

c)

n2

d)

n2-1

47.

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”)

a)

2n

b)

2n-1

c)

n2

d)

1

48.

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

a)

1+n

b)

2+n

c)

3+n

d)

n

49.

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”)

a)

1

b)

n

c)

2n

d)

n2

50.

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]

a)

1+n

b)

2+n

c)

3+n

d)

n

51.
What is the GCD of 18 and 12?
a)
6
b)
18
c)
12
d)
3
52.

t(n) = 4n+ 2 and g(n) = n2 using big oh notation what is no

a)

5

b)

4

c)

3

d)

2

53.

t(n) = n2 and g(n) = 3n+ 2 using omega notation what is no

a)

5

b)

4

c)

3

d)

2

54.

What is the time complexity for the following recurrence relation

T(n) = 4T(n/2) + n

a)

O(n2)

b)

O(n)

c)

O(nlogn)

d)

O(logn)

55.

What is the time complexity for the following recurrence relation

T(n) = 2T(n/2) + n

a)

O(n2)

b)

O(n)

c)

O(nlogn)

d)

O(logn)

56.
What is the GCD of 60 and 36?
a)
18
b)
12
c)
6
d)
3
57.

The graph represent which notation

a)

Big oh

b)

Omega

c)

Theta

d)

Sigma

58.

The graph represent which notation

a)

Big oh

b)

Omega

c)

Theta

d)

Sigma

59.

The graph represent which notation

a)

Big oh

b)

Omega

c)

Theta

d)

Sigma