0% found this document useful (0 votes)
18 views4 pages

Module 1 Algo Cncpts

Uploaded by

Bhubon Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Module 1 Algo Cncpts

Uploaded by

Bhubon Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Review Questions

3. Define data structures. Give some examples.


4. In how many ways can you categorize data structures? Explain each of them.
5. Discuss the applications of data structures.
6. Write a short note on different operations that can be performed on data structures.
7. Compare a linked list with an array.
8. Write a short note on abstract data type.
9. Explain the different types of data structures. Also discuss their merits and demerits.
10. Define an algorithm. Explain its features with the help of suitable examples.
11. Explain and compare the approaches for designing an algorithm.
12. What is modularization? Give its advantages.
13. Write a brief note on trees as a data structure.
14. What do you understand by a graph?
15. Explain the criteria that you will keep in mind while choosing an appropriate algorithm
to solve a particular problem.
16. What do you understand by time–space trade-off?
17. What do you understand by the efficiency of an algorithm?
18. How will you express the time complexity of a given algorithm?
19. Discuss the significance and limitations of the Big O notation.
20. Discuss the best case, worst case, average case, and amortized time complexity of
an algorithm.
21. Categorize algorithms based on their running time complexity.
22. Give examples of functions that are in Big O notation as well as functions that are not
in Big O notation.
23. Explain the little o notation.
24. Give examples of functions that are in little o notation as well as functions that are
not in little o notation.
25. Differentiate between Big O and little o notations.
26. Explain the Ω notation.
27. Give examples of functions that are in Ω notation as well as functions that are not in
Ω notation.
28. Explain the Θ notation.
29. Give examples of functions that are in Θ notation as well as functions that are not in
Θ notation.

Programming Exercises:
1. In each of the below mentioned scenario, deduce the general formula f(n) where n is the
input size for a given instance of the problem:
a. for(i=0;i<100;i+=2)
statement block;
Ans:
The loop runs from 0 to 100 with a step of 2.
Total iterations = 100/2=50
f(n) = 50 (constant)
b. for(i=1000;i>0;i/=2)
statement block;
Ans:
The loop divides i by 2 until it reaches 0.
Iterations = log⁡2(1000)
f(n) = O(\log n)

c. for(i=0;i<10;i++)

for(j=1; j<10;j*=2)

statement block;
Ans:
Outer loop: 10 iterations.
Inner loop: Iterates for log⁡2(10)
Total iterations = 10⋅log⁡2(10)
f(n) = O(n \log n)

d. for(i=0;i<10;i++)

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

statement block;
Ans:
Outer loop: 10 iterations.
Inner loop: 10 iterations per outer iteration.
Total iterations = 10*10=100
f(n) = O(n^2)

e. for(i=0;i<10;i++)

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

statement block;
Ans:
Outer loop: 10 iterations.
Inner loop: i+1 iterations for each i.
Total iterations = ∑i=010(i+1)=1+2+3+...+10
=10⋅(10+1) / 2
=55
f(n) = O(n^2)
2. What is a polynomial function and an exponential function? Provide examples in each of
the functions.
Ans:
Polynomial Function:
A function of the form f(n)=an^k+bn^(k−1)+...+c, where k is a
non-negative integer.
Example: f(n)=3n^2+2n+1
Exponential Function:
A function of the form f(n)=a⋅b^n, where b>1.
Example: f(n)=2^n
3. Let f(n)=2^n and g(n)=n^2. Compare the values of f(n) and g(n) for n=1 to n, and provide
the conclusion on the rate of increase among them.
Ans:
Calculations for f(n) and g(n) :
n f(n) = 2^n g(n) = n^2

1 2 1

2 4 4

3 8 9

4 16 16

5 32 25

6 64 36

7 128 49

8 256 64

9 512 81

10 1024 100

Observations:

1. At smaller values of n (e.g., n=1 and n=2), f(n) and g(n) are close, and g(n) might
even surpass f(n) temporarily.
2. From n=5 onwards, f(n) = 2^n grows much faster than g(n) = n^2, and this trend
continues as n increases.

Conclusion:
● The growth rate of f(n)=2^n = 2^n is exponential, while the growth rate of g(n) =
n^2 is polynomial.
● Exponential growth outpaces polynomial growth as n increases. Hence, f(n) will
eventually become much larger than g(n), regardless of how large g(n) is initially.

You might also like