50 Practice Questions on Data Structures and Algorithms
Arrays
1. What is a dynamic array? How does it differ from a static array?
2. Write a program to find the maximum subarray sum using Kadane's algorithm.
3. How do you rotate an array to the right by k steps?
4. Explain the concept of array slicing with an example.
5. Write a program to merge two sorted arrays without using extra space.
Linked List
6. What is the difference between singly and doubly linked lists?
7. Write a program to detect a loop in a linked list.
8. How can you reverse a linked list?
9. Explain the advantages of linked lists over arrays.
10. Write a program to merge two sorted linked lists.
Stack
11. What is a stack? Explain its LIFO property.
12. Write a program to implement a stack using arrays.
13. Explain how to evaluate a postfix expression using a stack.
14. Write a program to check for balanced parentheses in an expression.
15. How can a stack be used to reverse a string?
Queue
16. What is the difference between a queue and a deque?
17. Write a program to implement a queue using two stacks.
18. Explain circular queue and its advantages.
19. Write a program to implement a priority queue.
20. How does a queue differ from a stack in terms of usage?
Sorting
21. What is the time complexity of Quick Sort?
22. Write a program to perform merge sort on an array.
23. Explain the difference between stable and unstable sorting algorithms.
24. Write a program to implement bubble sort.
25. When is insertion sort preferred over other sorting algorithms?
Searching
26. Explain binary search and its time complexity.
27. Write a program to perform binary search on a sorted array.
28. What is linear search? When is it preferred over binary search?
29. Write a program to find the first and last occurrence of an element in a sorted array.
30. What are the limitations of binary search?