← Back to Subject
Data Structures and Algorithms • MCQ • Searching, Sorting and Hashing
Most Important 30 Objective Question - Searching, Sorting and Hashing
Q1. Linear search is also known as:
A) Sequential Search
B) Binary Search
C) Indexed Search
D) Hash Search
Answer: A
Explanation: Linear search checks elements one by one in sequence, so it is also called Sequential Search.

Q2. Binary search can be applied only on:
A) Unsorted list
B) Sorted list
C) Linked list only
D) Graph only
Answer: B
Explanation: Binary search requires the elements to be arranged in sorted order.

Q3. Time complexity of linear search in worst case is:
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
Answer: C
Explanation: In the worst case, every element must be checked one by one.

Q4. Time complexity of binary search is:
A) O(n)
B) O(log n)
C) O(n²)
D) O(1)
Answer: B
Explanation: Binary search repeatedly divides the search space into half.

Q5. Which sorting algorithm repeatedly swaps adjacent elements?
A) Selection Sort
B) Bubble Sort
C) Merge Sort
D) Heap Sort
Answer: B
Explanation: Bubble sort compares adjacent elements and swaps them if needed.

Q6. Which sorting algorithm selects the minimum element repeatedly?
A) Bubble Sort
B) Quick Sort
C) Selection Sort
D) Merge Sort
Answer: C
Explanation: Selection sort repeatedly selects the smallest element and places it correctly.

Q7. Which sorting algorithm works by dividing the list into two halves?
A) Merge Sort
B) Bubble Sort
C) Insertion Sort
D) Selection Sort
Answer: A
Explanation: Merge sort uses divide and conquer by splitting the list into halves.

Q8. Which sorting algorithm is best for small datasets?
A) Quick Sort
B) Merge Sort
C) Insertion Sort
D) Heap Sort
Answer: C
Explanation: Insertion sort performs well for small or nearly sorted datasets.

Q9. Quick sort is based on:
A) Greedy method
B) Divide and Conquer
C) Dynamic Programming
D) Backtracking
Answer: B
Explanation: Quick sort selects a pivot and divides the array recursively.

Q10. Heap sort uses which data structure?
A) Stack
B) Queue
C) Heap
D) Linked List
Answer: C
Explanation: Heap sort is based on heap data structure.

Q11. Which sorting algorithm is stable?
A) Quick Sort
B) Merge Sort
C) Heap Sort
D) Selection Sort
Answer: B
Explanation: Merge sort maintains the relative order of equal elements.

Q12. Hashing is mainly used for:
A) Sorting
B) Fast Searching
C) Deletion only
D) Traversal
Answer: B
Explanation: Hashing provides fast searching using a hash function.

Q13. Hash function is used to:
A) Sort data
B) Map key to memory location
C) Delete elements
D) Traverse list
Answer: B
Explanation: Hash function converts a key into an index or address.

Q14. Collision in hashing occurs when:
A) Two keys map to same location
B) Data gets deleted
C) Array becomes full
D) Search becomes slow
Answer: A
Explanation: Collision occurs when multiple keys generate the same hash value.

Q15. Which is not a sorting algorithm?
A) Bubble Sort
B) Merge Sort
C) Binary Search
D) Quick Sort
Answer: C
Explanation: Binary Search is a searching algorithm, not a sorting algorithm.

Q16. Insertion sort inserts element in:
A) Beginning
B) Correct sorted position
C) Last position only
D) Random position
Answer: B
Explanation: Insertion sort places each element into its proper sorted position.

Q17. Selection sort performs how many swaps approximately?
A) Very few
B) Very many
C) Infinite
D) No swaps
Answer: A
Explanation: Selection sort minimizes the number of swaps.

Q18. Bubble sort compares:
A) Random elements
B) Adjacent elements
C) First and last only
D) Middle elements only
Answer: B
Explanation: Bubble sort works by comparing neighboring elements.

Q19. Quick sort uses:
A) Queue
B) Pivot element
C) Stack only
D) Hash table
Answer: B
Explanation: Quick sort selects a pivot element for partitioning.

Q20. Merge sort complexity is:
A) O(n log n)
B) O(n²)
C) O(log n)
D) O(1)
Answer: A
Explanation: Merge sort has efficient O(n log n) time complexity.

Q21. Heap sort worst-case complexity is:
A) O(n²)
B) O(n log n)
C) O(n)
D) O(log n)
Answer: B
Explanation: Heap sort performs sorting in O(n log n) time.

Q22. Which sorting method is simplest?
A) Bubble Sort
B) Heap Sort
C) Merge Sort
D) Quick Sort
Answer: A
Explanation: Bubble sort is the easiest sorting algorithm to understand and implement.

Q23. Binary search compares target with:
A) First element
B) Last element
C) Middle element
D) Random element
Answer: C
Explanation: Binary search first checks the middle element.

Q24. Hash table stores:
A) Sorted data
B) Key-value pairs
C) Tree nodes
D) Queue elements
Answer: B
Explanation: Hash table stores data using key-value mapping.

Q25. Which sorting algorithm is best average case?
A) Quick Sort
B) Bubble Sort
C) Selection Sort
D) Linear Search
Answer: A
Explanation: Quick sort performs very efficiently in average case.

Q26. Linear search is suitable for:
A) Very large sorted data
B) Small unsorted data
C) Hash tables
D) Graphs only
Answer: B
Explanation: Linear search is simple and suitable for small unsorted lists.

Q27. Rehashing is done when:
A) Stack overflows
B) Too many collisions occur
C) Queue is empty
D) Tree becomes unbalanced
Answer: B
Explanation: Rehashing helps reduce collisions in hash tables.

Q28. Which sorting does not require extra memory?
A) Merge Sort
B) Bubble Sort
C) Quick Sort
D) Heap Sort
Answer: B
Explanation: Bubble sort is an in-place sorting algorithm.

Q29. Hashing improves:
A) Searching speed
B) Sorting speed
C) Graph traversal
D) Tree height
Answer: A
Explanation: Hashing is mainly used for faster searching operations.

Q30. Which search is fastest for direct access?
A) Linear Search
B) Binary Search
C) Hashing
D) Bubble Sort
Answer: C
Explanation: Hashing provides almost constant-time searching in many cases.
Google AdSense Ad Placement Here 📢