0% found this document useful (0 votes)
8 views

Top 100 Data Structures and Algorithms MCQs With Answers

The document contains a collection of 100 multiple-choice questions (MCQs) related to data structures and algorithms, categorized into sections such as Abstract Data Types, Trees, Graphs, Sorting, Hashing, and Complexity. Each question is accompanied by four options and the correct answer. The content serves as a study guide for understanding key concepts in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Top 100 Data Structures and Algorithms MCQs With Answers

The document contains a collection of 100 multiple-choice questions (MCQs) related to data structures and algorithms, categorized into sections such as Abstract Data Types, Trees, Graphs, Sorting, Hashing, and Complexity. Each question is accompanied by four options and the correct answer. The content serves as a study guide for understanding key concepts in computer science.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Top 100 Data Structures and Algorithms MCQs with answers

1-10: Abstract Data Types and Basic Structures

1. Which data structure uses LIFO order?

o A) Queue B) Stack C) List D) Tree


Ans: B

2. Which data structure uses FIFO order?

o A) Stack B) Queue C) Set D) Tree


Ans: B

3. Which structure allows constant-time insertion and deletion at both ends?

o A) Array B) Linked List C) Deque D) Stack


Ans: C

4. What is the maximum number of children a binary tree node can have?

o A) 1 B) 2 C) 3 D) Unlimited
Ans: B

5. Which of these is not a linear data structure?

o A) Queue B) Stack C) Tree D) Array


Ans: C

6. Which is used to store elements in key-value pairs?

o A) Array B) Set C) HashMap D) Queue


Ans: C

7. Which data structure does not allow duplicate elements?

o A) Array B) Stack C) Set D) List


Ans: C

8. What is the default traversal method for stacks?

o A) BFS B) DFS C) Level Order D) Inorder


Ans: B

9. Which data structure supports O(1) insertion and deletion at the front?

o A) Stack B) Queue C) Deque D) Array


Ans: C

10. Which ADT supports string operations like substring and concatenation?

o A) Stack B) Set C) String D) Queue


Ans: C

11–30: Trees and Traversals


11. Which traversal is used for BST to get sorted output?

o A) Inorder B) Preorder C) Postorder D) BFS


Ans: A

12. Preorder traversal follows:

o A) Left, Root, Right B) Root, Left, Right C) Left, Right, Root D) Right, Left, Root
Ans: B

13. A complete binary tree has:

o A) All levels completely filled

o B) All nodes with two children

o C) Last level not necessarily complete

o D) All nodes in left subtree


Ans: A

14. Which tree data structure is balanced and maintains BST property?

o A) AVL Tree B) Heap C) Binary Tree D) Trie


Ans: A

15. The height of a complete binary tree with n nodes is:

o A) log n B) n C) n log n D) √n
Ans: A

16–30: Trees and Traversals (Continued)

16. Postorder traversal visits nodes in the order:

• A) Root, Left, Right

• B) Left, Right, Root

• C) Left, Root, Right

• D) Right, Left, Root


Ans: B

17. The height of an empty tree is:

• A) 0

• B) 1

• C) -1

• D) Undefined
Ans: C

18. A binary search tree property is:


• A) Left child is greater than root

• B) Right child is smaller than root

• C) Left subtree values < root < right subtree values

• D) No specific order
Ans: C

19. Which of the following is a balanced tree?

• A) AVL tree

• B) Binary tree

• C) BST without balance

• D) Heap
Ans: A

20. A min-heap always stores:

• A) Smallest element at root

• B) Largest element at root

• C) Median element at root

• D) Random element at root


Ans: A

21. Height balanced trees maintain:

• A) Left and right subtree heights differ by at most 1

• B) Left subtree taller

• C) Right subtree taller

• D) No height restriction
Ans: A

22. Which traversal prints nodes level by level?

• A) Inorder

• B) Preorder

• C) Postorder

• D) Level order
Ans: D

23. Which traversal is best suited for expression trees?

• A) Inorder

• B) Preorder
• C) Postorder

• D) Level order
Ans: C

24. Number of null pointers in a binary tree with n nodes is:

• A) n

• B) n + 1

• C) n - 1

• D) 2n
Ans: B

25. Which tree traversal uses a queue data structure?

• A) Inorder

• B) Preorder

• C) Level order

• D) Postorder
Ans: C

26. Which tree traversal is naturally recursive?

• A) Inorder

• B) Level order

• C) BFS

• D) None
Ans: A

27. Which of the following is NOT true for a binary search tree?

• A) Inorder traversal gives sorted output

• B) Left child < root

• C) Right child > root

• D) It must be a complete binary tree


Ans: D

28. Which tree structure is used in priority queue implementation?

• A) Binary Search Tree

• B) AVL Tree

• C) Heap
• D) Trie
Ans: C

29. Which of the following is NOT a binary tree traversal?

• A) Inorder

• B) Postorder

• C) Preorder

• D) Hash order
Ans: D

30. The maximum number of nodes at level l in a binary tree is:

• A) l

• B) 2^l

• C) l^2

• D) 2*l
Ans: B

31–50: Graphs and Traversals

31. Which traversal is used in BFS?

• A) Stack B) Queue C) Recursion D) Heap


Ans: B

32. DFS uses which data structure?

• A) Queue B) Stack C) Linked List D) Priority Queue


Ans: B

33. A graph is cyclic if:

• A) It contains a loop

• B) It is connected

• C) It has isolated vertices

• D) It has parallel edges


Ans: A

34. The number of edges in a complete graph of n vertices is:

• A) n(n-1)/2 B) n C) n^2 D) n(n+1)/2


Ans: A

35. Which algorithm is used to find Minimum Spanning Tree?


• A) BFS B) Dijkstra C) Prim D) Bellman-Ford
Ans: C

36. Which algorithm is better for dense graphs?

• A) Kruskal B) Prim C) DFS D) BFS


Ans: B

37. How many spanning trees can a complete graph with n vertices have?

• A) n^(n-2) B) n(n-1) C) n^2 D) n-1


Ans: A

38. In an undirected graph, the sum of degrees is:

• A) Equal to twice the number of edges

• B) Equal to number of vertices

• C) Equal to number of edges

• D) Half the number of edges


Ans: A

39. A tree is a graph:

• A) With one cycle

• B) Without cycles

• C) With multiple components

• D) That is disconnected
Ans: B

40. For BFS traversal in graphs, we need:

• A) Recursion B) Stack C) Queue D) Linked List


Ans: C

51–70: Sorting and Searching

51. Time complexity of Merge Sort is:

• A) O(n) B) O(log n) C) O(n log n) D) O(n^2)


Ans: C

52. Worst-case time for Quick Sort:

• A) O(n log n) B) O(n^2) C) O(n) D) O(log n)


Ans: B

53. Best case for Insertion Sort:

• A) O(n log n) B) O(n^2) C) O(n) D) O(1)


Ans: C
54. Bubble sort is best suited for:

• A) Large input B) Random input C) Nearly sorted input D) Unsorted large input
Ans: C

55. Which sorting is not based on comparisons?

• A) Quick Sort B) Merge Sort C) Heap Sort D) Counting Sort


Ans: D

56. Which is not a stable sorting algorithm?

• A) Merge Sort B) Insertion Sort C) Quick Sort D) Bubble Sort


Ans: C

57. Binary Search works on:

• A) Unsorted list B) Sorted list C) Linked list D) Queue


Ans: B

58. What is the time complexity of binary search?

• A) O(n) B) O(n log n) C) O(log n) D) O(1)


Ans: C

59. Linear search is preferred when:

• A) List is sorted B) List is small C) List is large D) None


Ans: B

60. Heap sort is based on:

• A) Min heap B) Max heap C) Both A and B D) Stack


Ans: C

71–90: Hashing and Design Techniques

71. What is the primary goal of hashing?

• A) Reduce memory B) Enable fast access C) Sorting D) Compression


Ans: B

72. What is collision in hashing?

• A) When key already exists

• B) When two keys hash to same index

• C) When load is exceeded

• D) When table is empty


Ans: B

73. Load factor in hashing is:

• A) Table size / key size


• B) Number of keys / table size

• C) Table size / collisions

• D) Keys * slots
Ans: B

74. Which technique is used in dynamic programming?

• A) Divide and conquer

• B) Memoization

• C) Greedy approach

• D) Heaps
Ans: B

75. Greedy algorithms are used in:

• A) Shortest path B) TSP C) Sorting D) Binary search


Ans: A

76. Divide and Conquer is used in:

• A) Merge Sort B) Insertion Sort C) Counting Sort D) Radix Sort


Ans: A

77. Dynamic programming is suitable for:

• A) Independent subproblems

• B) Overlapping subproblems

• C) Sorted data

• D) Linear recursion
Ans: B

78. Dijkstra’s algorithm fails when:

• A) Negative weights B) Zero weight C) Positive weights D) Loops


Ans: A

79. Kruskal’s algorithm uses:

• A) BFS B) DFS C) Disjoint sets D) Stack


Ans: C

80. Topological sorting applies to:

• A) Undirected graph B) Directed cyclic graph C) Directed acyclic graph D) Trees


Ans: C

91–100: Complexity and NP-Completeness


91. Time complexity of Merge Sort is:

• A) O(n^2) B) O(n log n) C) O(n) D) O(log n)


Ans: B

92. NP-complete problems are:

• A) Easily solvable B) Verified in polynomial time C) Sorted D) None


Ans: B

93. Which case describes the least time an algorithm takes?

• A) Worst B) Average C) Best D) Amortized


Ans: C

94. Space complexity refers to:

• A) CPU time B) Memory used C) Disk space D) Stack usage only


Ans: B

95. A problem is in P if:

• A) Solvable in polynomial time B) Solvable in exponential time C) Not solvable D) Only guessed
Ans: A

96. Asymptotic upper bound is represented by:

• A) Theta B) Omega C) Big-O D) Small o


Ans: C

97. Which function grows the fastest?

• A) log n B) n C) n log n D) 2^n


Ans: D

98. Lower bound means:

• A) Worst case B) Minimum required time C) Maximum time D) Space limit


Ans: B

99. If an algorithm runs in O(n^2), doubling n increases time by:

• A) 2x B) 4x C) 3x D) n
Ans: B

100.Which of the following is not NP-complete?

• A) SAT B) Travelling Salesman C) Fibonacci sequence D) Hamiltonian path


Ans: C

You might also like