Skip to main content

Data Structures MCQs with Answers

Practice important Data Structures MCQs with answers and explanations.

Multiple Choice Questions

Q681: What is the time complexity of bubble sort?
  • A: O(N)
  • B: O(N log N)
  • C: O(N^2)
  • D: O(log N)
View Answer
C

Q682: In bubble sort, what happens to the largest element in each pass?
  • A: It is moved to the start of the array
  • B: It is moved to the end of the array
  • C: It is moved to the middle of the array
  • D: It is not moved
View Answer
B

Q683: What is the key difference between selection sort and insertion sort?
  • A: Selection sort only finds the smallest element while insertion sort places each element in the correct position
  • B: Selection sort places elements in their correct position while insertion sort finds the smallest element
  • C: Selection sort is faster than insertion sort
  • D: Insertion sort is more memory efficient than selection sort
View Answer
A

Q684: What is the purpose of the swapped variable in bubble sort?
  • A: To keep track of the number of swaps
  • B: To determine if the array is already sorted
  • C: To track the bound of the array being sorted
  • D: To count the number of comparisons made
View Answer
B

Q685: Which of the following sorting algorithms is known to be an in-place sort?
  • A: Selection Sort
  • B: Insertion Sort
  • C: Bubble Sort
  • D: All of the above
View Answer
D

Q686: What will the array look like after the first pass of bubble sort for the array [5, 12, 7, 19]?
  • A: [5, 7, 12, 19]
  • B: [12, 5, 7, 19]
  • C: [5, 7, 19, 12]
  • D: [5, 12, 7, 19]
View Answer
B

Q687: How many comparisons are required in the worst-case scenario for insertion sort with N elements?
  • A: N
  • B: N log N
  • C: N^2
  • D: log N
View Answer
C

Q688: What does the outer loop of the bubble sort algorithm do?
  • A: Repeats the swapping process until no swaps are needed
  • B: Swaps neighboring elements
  • C: Finds the smallest element in the array
  • D: Inserts elements into their correct positions
View Answer
A

Q689: How does the insertionSort function insert an element into the sorted portion of the array?
  • A: By comparing it with all elements in the array
  • B: By shifting elements to make space
  • C: By swapping it with adjacent elements
  • D: By sorting the entire array again
View Answer
B

Q690: What is the time complexity of merge sort?
  • A: O(n)
  • B: O(n^2)
  • C: O(n log n)
  • D: O(log n)
View Answer
C

Test Your Knowledge

Take a timed quiz on Data Structures

🚀 Start Quiz Now