Topic Wise Questions
Topic Wise Questions
1. What is the time complexity of the best, worst, and average case of a linear
search algorithm?
2. Explain the difference between time complexity and space complexity. Give
examples.
3. Given an algorithm with time complexity O(n log n), explain what kind of
algorithm it could be and why.
4. What is the difference between malloc and calloc functions in C? How does free
work?
6. What are the advantages and disadvantages of using recursion? Compare it with
iteration.
7. For an array of size n, how would you calculate the address of an element in a
multi-dimensional array?
8. How are arrays stored in memory? Explain row-major and column-major order for
multi-dimensional arrays.
10. Write the time complexity for basic array operations such as accessing an
element, searching for an element, and inserting/deleting an element.
12. What is a string in C? How does the function strlen() calculate the length of a
string?
14. Explain the difference between passing an array to a function by value and by
reference.
15. Write a recursive algorithm for computing the factorial of a number. Analyze
its time complexity.
16. If the input size n doubles, how does it affect the time complexity for
algorithms with O(n), O(log n), and O(n^2)?
19. How would you reverse a string using recursion and using iteration? Compare the
approaches.
20. What are the implications of dynamic memory allocation in terms of performance
and memory usage?
21. Explain the basic operations of a stack and their time complexities.
23. What is a stack overflow, and how can it occur in a recursive function?
24. Explain the implementation of a stack using arrays. What is the drawback of
this implementation?
29. What is the difference between a circular queue and a linear queue?
30. How does a circular queue help in avoiding the limitation of a static queue
implementation?
33. How is a deque (double-ended queue) implemented? What are its applications?
34. Explain the difference between enqueue and dequeue operations in queues.
35. What are the advantages of using a circular queue in system-level applications
like printers or process scheduling?
36. How does a priority queue differ in terms of insertion and deletion compared to
a regular queue?
37. What is the worst-case time complexity for performing an insertion in a stack
implemented using arrays?
39. Describe the circular queue insertion and deletion operations with pseudocode.
40. What are the conditions for overflow and underflow in a circular queue?
41. What is a linked list? Compare it with arrays in terms of memory allocation and
access times.
42. Describe how insertion and deletion are performed in a singly linked list.
43. Write the time complexity for the basic operations (searching, insertion, and
deletion) in a singly linked list.
44. Explain how a doubly linked list differs from a singly linked list.
45. What are the advantages and disadvantages of using a doubly linked list?
46. Write the time complexity of searching, insertion, and deletion operations in a
doubly linked list.
47. What is a circular linked list, and what are its applications?
51. Define a binary tree. What is the time complexity for searching an element in a
binary search tree?
52. What is the difference between a binary tree and a binary search tree?
53. Explain pre-order, in-order, and post-order tree traversal. What are their
applications?
54. What is the difference between a complete binary tree and a perfect binary
tree?
56. Explain the concept of balancing in AVL trees and why it is necessary.
57. What are the different types of rotations in AVL trees? Give examples.
58. Describe the process of inserting and deleting a node in an AVL tree.
60. What is the time complexity for searching in a balanced AVL tree?
62. What is a B-tree? Where is it used, and how does it differ from a binary tree?
63. Explain the structure of a B+ tree and its advantages in database indexing.
64. Compare the advantages of using an AVL tree over a binary search tree.
66. What is tree traversal, and how is it different in depth-first and breadth-
first search?
67. Write the time complexity for the different tree traversal techniques.
68. Explain the term "strictly binary tree". How is it different from a regular
binary tree?
69. What is a degenerate tree, and how does it affect the time complexity of search
operations?
73. How is a graph represented using adjacency lists and adjacency matrices?
74. Explain depth-first search (DFS) and breadth-first search (BFS) for graph
traversal.
76. Write the time complexity for BFS and DFS graph traversal algorithms.
78. Compare BFS and DFS in terms of time complexity and space complexity.
81. What are the different types of searching techniques? Explain binary search.
82. What is the time complexity of binary search? How is it better than linear
search?
83. Explain quick sort. What is its average case and worst-case time complexity?
85. What is the time complexity of bubble sort, and why is it not preferred for
large datasets?
87. Explain the difference between selection sort and insertion sort.
90. Explain the concept of collisions in hashing and how they are resolved.
91. What is a collision resolution technique? Explain linear probing and chaining.
92. What is double hashing, and how does it help in collision resolution?
94. Write the time complexity for the basic hashing operations (insertion, search,
deletion).
99. Write pseudocode for implementing hash insertion using linear probing.
100. Explain how rehashing works and why it is necessary in dynamic hash tables.