Data Structures and Algorithms - Questions
Unit I: Abstract Data Types (ADTs)
1. What is the time complexity for accessing an element in an array-based List ADT?
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
Answer: a) O(1)
2. Which of the following is true for a doubly linked list?
a) It has only a forward pointer.
b) It has both forward and backward pointers.
c) It has no pointers.
d) It is circular by default.
Answer: b) It has both forward and backward pointers.
3. What does a circular linked list's last node point to?
a) NULL
b) The first node
c) The middle node
d) Itself
Answer: b) The first node
4. Which operation is typically expensive in an array-based List ADT?
a) Traversal
b) Access
c) Insertion in the middle
d) Accessing the first element
Answer: c) Insertion in the middle
5. Which of the following applications uses a linked list?
a) Polynomial Manipulation
b) Hashing
c) Sorting
d) Binary Search
Answer: a) Polynomial Manipulation
Unit II: Stack
6. Which of the following is NOT a stack operation?
a) Push
b) Pop
c) Enqueue
d) Peek
Answer: c) Enqueue
7. What is the postfix expression for the infix expression (A + B) * C?
a) AB + C*
b) AB * C +
c) ABC+ *
d) ABC*+
Answer: a) AB + C*
8. What data structure is used for evaluating arithmetic expressions?
a) Stack
b) Queue
c) Linked List
d) Graph
Answer: a) Stack
9. In a circular queue, what happens when the rear pointer exceeds the array size?
a) It stops.
b) It is reset to the front.
c) It points to NULL.
d) An error is raised.
Answer: b) It is reset to the front.
10. Which data structure is used in the conversion of infix to postfix?
a) Queue
b) Stack
c) Tree
d) Linked List
Answer: b) Stack
Unit III: Tree ADT
11. What is the degree of a binary tree node?
a) 1
b) 2
c) At most 2
d) None of the above
Answer: c) At most 2
12. Which traversal of a binary tree visits the root node first?
a) Inorder
b) Preorder
c) Postorder
d) Level Order
Answer: b) Preorder
13. What is a complete binary tree?
a) All levels are completely filled.
b) All nodes have two children.
c) All leaf nodes are at the same level.
d) All levels except possibly the last are completely filled, and all nodes in the last level
are as far left as possible.
Answer: d) All levels except possibly the last are completely filled, and all nodes in the
last level are as far left as possible.
14. Which tree allows faster searching than a binary search tree?
a) AVL Tree
b) Threaded Binary Tree
c) Expression Tree
d) Heap
Answer: a) AVL Tree
15. In a binary search tree, which traversal yields elements in sorted order?
a) Preorder
b) Postorder
c) Inorder
d) Level Order
Answer: c) Inorder
Unit IV: Graph
16. Which of the following is NOT a type of graph?
a) Directed graph
b) Weighted graph
c) Doubly-linked graph
d) Undirected graph
Answer: c) Doubly-linked graph
17. What is the time complexity of Depth First Search (DFS)?
a) O(V)
b) O(V + E)
c) O(E)
d) O(V × E)
Answer: b) O(V + E)
18. Which traversal algorithm uses a queue?
a) Depth First Search
b) Breadth First Search
c) Topological Sort
d) Euler Circuit Finder
Answer: b) Breadth First Search
19. What is a cut vertex?
a) A vertex that connects two graphs.
b) A vertex whose removal increases the number of connected components.
c) A vertex that has no edges.
d) A vertex that belongs to an Euler circuit.
Answer: b) A vertex whose removal increases the number of connected components.
20. Which sorting algorithm is typically used in Topological Sort?
a) Merge Sort
b) Heap Sort
c) Any stable sort
d) No sorting is used; DFS is employed.
Answer: d) No sorting is used; DFS is employed.
Unit V: Searching and Sorting
21. What is the time complexity of Binary Search?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
22. Which sorting algorithm works by repeatedly swapping adjacent elements that are out
of order?
a) Bubble Sort
b) Selection Sort
c) Insertion Sort
d) Shell Sort
Answer: a) Bubble Sort
23. What is the key feature of a hash table?
a) Fast searching based on keys.
b) It uses linked lists.
c) It works only for integers.
d) It uses trees for indexing.
Answer: a) Fast searching based on keys.
24. Which hashing technique handles collisions by linking elements in the same index?
a) Open Addressing
b) Rehashing
c) Separate Chaining
d) Extendible Hashing
Answer: c) Separate Chaining
25. Which sorting algorithm is based on the concept of dividing elements into buckets?
a) Radix Sort
b) Shell Sort
c) Bubble Sort
d) Selection Sort
Answer: a) Radix Sort