What is the time complexity of accessing an element in an array by index?
a) O(n)
b) O(log n)
c) O(1)
d) O(n^2)
Answer: c) O(1)
What is the time complexity of inserting an element at the beginning of a linked list?
a) O(n)
b) O(log n)
c) O(1)
d) O(n^2)
Answer: c) O(1)
What is the best-case time complexity of quicksort?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: b) O(n log n)
What is the worst-case time complexity of quicksort?
a) O(n log n)
b) O(n)
c) O(n^2)
d) O(log n)
Answer: c) O(n^2)
What is the time complexity of searching for an element in a balanced binary search tree (BST)?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
Answer: b) O(log n)
What is the time complexity of merging two sorted arrays of size n?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
What is the time complexity of deleting an element from a linked list given a pointer to that element?
a) O(1)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(1)
What is the average-case time complexity of binary search?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
Answer: b) O(log n)
What is the time complexity of finding the maximum element in an unsorted array?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(1)
Answer: b) O(n)
What is the time complexity of the bubble sort algorithm in the worst case?
a) O(n)
b) O(n log n)
c) O(n^2)
d) O(log n)
Answer: c) O(n^2)
What is the time complexity of inserting an element into a max-heap?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
Answer: b) O(log n)
What is the time complexity of deleting the minimum element from a min-heap?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
Answer: b) O(log n)
What is the time complexity of traversing a binary tree?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
What is the time complexity of the merge sort algorithm?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: a) O(n log n)
What is the time complexity of the selection sort algorithm?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: d) O(n^2)
What is the time complexity of searching for an element in an unbalanced binary search tree (BST)?
a) O(n)
b) O(log n)
c) O(1)
d) O(n log n)
Answer: a) O(n)
What is the time complexity of checking if an element exists in a hash table with n elements?
a) O(n)
b) O(log n)
c) O(1)
d) O(n^2)
Answer: c) O(1)
What is the time complexity of the insertion sort algorithm in the best case?
a) O(n log n)
b) O(n)
c) O(log n)
d) O(n^2)
Answer: b) O(n)
What is the time complexity of deleting an element from an array, given its index?
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
Answer: b) O(n)
What is the time complexity of the Fibonacci sequence using dynamic programming?
a) O(n)
b) O(log n)
c) O(1)
d) O(n^2)
Answer: a) O(n)
Basic Concepts
Non-Linear Data Structures MCQs
Sorting and Searching Algorithms MCQs
- Data Structures MCQs 1
- Data Structures MCQs 2
- Data Structures MCQs 3
- Data Structures MCQs 4
- Data Structures MCQs 5
- Stacks Solved MCQs
- Queues MCQs
- pointer mcqs
- Array MCQs