Data Structures - Very Short Answer Questions (All 40 Answers)
1. 1. Bubble Sort:
Best: O(n), Average: O(n²), Worst: O(n²), Space: O(1)
2. 2. Selection Sort:
Best: O(n²), Average: O(n²), Worst: O(n²), Space: O(1)
3. 3. Insertion Sort:
Best: O(n), Average: O(n²), Worst: O(n²), Space: O(1)
4. 4. Merge Sort:
Best: O(n log n), Average: O(n log n), Worst: O(n log n), Space: O(n)
5. 5. Quick Sort:
Best: O(n log n), Average: O(n log n), Worst: O(n²), Space: O(log n)
6. 6. Omega Notation:
It gives the best-case time complexity (lower bound) of an algorithm.
7. 7. Theta Notation:
Represents average-case or tight bound when upper and lower bounds are equal.
8. 8. Big-O Notation:
Describes the worst-case time or space complexity (upper bound).
9. 9. Little-o Notation:
Represents a non-tight upper bound (algorithm grows slower than a certain function).
10. 10. Little-omega Notation:
Represents a non-tight lower bound (algorithm grows faster than a certain function).
11. 11. LIFO:
Last In First Out; used in stack.
12. 12. FIFO:
First In First Out; used in queue.
13. 13. Push Operation (Stack):
Add element to top of stack.
14. 14. Pop Operation (Stack):
Remove element from top of stack.
15. 15. Enqueue Operation:
Add element to rear of queue.
16. 16. Dequeue Operation:
Remove element from front of queue.
17. 17. Display Stack:
Print all elements from top to bottom.
18. 18. Display Queue:
Print all elements from front to rear.
19. 19. Display Circular Queue:
Print elements from front to rear, wrapping if needed.
20. 20. Full and Empty (Linear Queue):
Full: rear==MAX-1, Empty: front==-1 or front > rear
21. 21. Full/Empty (Circular Queue):
Full: (rear+1)%size==front, Empty: front==-1
22. 22. Stack Conditions:
Full: top==MAX-1, Empty: top==-1
23. 23. Evaluate Prefix:
Traverse right to left; use stack to evaluate.
24. 24. Evaluate Postfix:
Traverse left to right; use stack to evaluate.
25. 25. Applications of Stack:
Used in expression evaluation, recursion, undo operations.
26. 26. Applications of Queue:
Used in CPU scheduling, disk scheduling, printer spooling.
27. 27. Applications of Circular Queue:
Used in memory management, buffering data.
28. 28. Stack vs Queue:
Stack: LIFO, one end; Queue: FIFO, two ends.
29. 29. Recursion & Stack:
Function calls use system stack for execution tracing.
30. 30. Malloc vs Calloc:
Malloc: allocates uninitialized memory; Calloc: allocates zero-initialized memory.
31. 31. Static vs Dynamic Allocation:
Static: compile-time; Dynamic: runtime using malloc/calloc.
32. 32. free():
Used to deallocate memory dynamically allocated.
33. 33. DMA Applications:
Used in OS, drivers, and large dynamic memory handling.
34. 34. Need for DMA:
To efficiently handle memory at runtime for variable-size data.
35. 35. Merits/Demerits of Dynamic Allocation:
+Flexible, -Complex and risk of fragmentation.
36. 36. Merits/Demerits of Static Allocation:
+Simple, -Inflexible, memory wastage possible.
37. 37. Self-Referential Structure:
A structure that contains pointer to same structure type.
38. 38. Linked List:
A collection of nodes with data and pointer to next node.
39. 39. Merits/Demerits of S/C/D Lists:
Singly: Simple; Circular: efficient loop; Doubly: bidirectional. Each has use-case.
40. 40. Applications of S/C/D Linked Lists:
Used in navigation systems, music playlists, undo features, memory allocators.