Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Unit 1

Q 1.Efficiency of an algorithm is measured in terms of_______ and ______


complexity.

(a)time,space (b)time,data

(c)data,space (d)processor,memory

Q2.What is the space complexity of following function:

int sum(a,n)

int i,s=0;

for(i=0;i<n;i++)

s+=a[i];

return s;

(a)n+1 (b)2n

(c)n+3 (d)2n+1

Q3. Space complexity is

(a)how long does it take to (b)how much memory is needed to

find a solution. perform the search.

(c)is the strategy guaranteed to (d)None of the above

find the solution when there is one.


Q4. The space factor when determining the efficiency of an algorithmis measured

by:

(a)Counting the maximum memory needed by the algorithm

(b)Counting the minimum memory needed by the algorithm

(c)Counting the average memory needed by the algorithm

(d)Counting the maximum disk space needed by the algorithm

Q5. What is the space complexity of Quick Sort

(a)O(n) (b)Ω(n)

(c)O(log(n)) (d)O(1)

Q6. What is the space complexity of Merge Sort

(a)O(n) (b)Ω(n)

(c) Ω(1) (d)O(1)

Q7. What is the space complexity of Selection Sort

(a)O(n) (b)Ω(n)

(c) Ω(1) (d)O(1)

Q8. How much memory is needed to store: int array[3][3]

(a)20 (b)9

(c) 18 (d)15

Q9. What is meant by space complexity O(1)?

(a)Space required to process data is constant

(b)Space required to process data is zero

(c)Space required to process data is variable

(d)None of the above


Q10. _________ is the extra or temporary space used by the algorithm during

its execution.

(a)Input space (b) Auxiliary space

(c)Output space (d) Short-term space

Q11. Space complexity can be calculated for what kind of data

(a)Static (b) Dynamic

(c)Both a and b (d) None

Q12. Determine space complexity of following function:

int add()

int i,j,n;

int a[n][n], b[n][n],c [n][n];

for(i=0;i<n;i++)

for(j=0;j<n;j++)

C[i][j]=a[i][j]+b[i][j];

(a)3n+3 (b)3n2+3
(c)n2+3 (d)2n2+2n+1

Q13. Determine space complexity of following function:

int multiply()

int i,j,k,n;

int a[n][n], b[n][n], c[n][n];

for(i=0;i<n;i++)

for(j=0;j<n;j++)

for( k=0;k<n;k++)

c[i][j]+=a[i][k]+b[k][j];

(a)4n2+1 (b)4n+4

(c)3n2+4 (d)4n2+3

Q14.O(n) lies in which bound?

(a)Lower Bound (b)Average Bound

(c)Central Bound (d)Upper bound

Q15.Which of the following lies in lower bound:

(a)1 (b)nlogn

(c)n (d)n2
Q16.Which of the following lies in upper bound:

(a)logn (b)nlogn

(c)1 (d)n

Q17.What is the asymptotic notation for upper bound?

(a)Big-O (b)Big-Omega

(c)Theta (d)Beta

Q18. What is the asymptotic notation for lower bound?

(a)Big-O (b)Big-Omega

(c)Theta (d)Beta

Q18. What is the asymptotic notation for average bound?

(a)Big-O (b)Big-Omega

(c)Theta (d)Beta

Q19.For upper bound

(a)f(n)≤cg(n) (b) f(n)≥cg(n)

(c)c1g(n) ≤f(n)≤c 2g(n) (d)none of these

Q20. For the asymptotic notation Big-Omega (Ω)

(a)f(n)≤cg(n) (b) f(n)≥cg(n)

(c)c1g(n) ≤f(n)≤c 2g(n) (d)none of these

Q21. For average bound

(a)f(n)≤cg(n) (b) f(n)≥cg(n)

(c)c1g(n) ≤f(n)≤c 2g(n) (d)none of these


Q22.What is space complexity of following function:

swap(a,b)

int a,b,t;

t=a;

a=b;

b=t;

(a)O(n) (b)Ω(1)

(c)Ω(log(n)) (d)O(1)

You might also like