Data Structures Mcq 1
Data Structures Mcq 1
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
a) Queue
b) Stack
c) Array
d) Linked List
a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
5. In a queue, insertion is done at the ___ and deletion is done from the ___
a) Front, Rear
b) Rear, Front
c) Rear, Rear
d) Front, Front
a) Level-order
b) Breadth-first
c) Inorder/Preorder/Postorder
d) None of the above
7. Which of the following is not a self-balancing binary search tree?
a) AVL Tree
b) Red-Black Tree
c) B-Tree
d) Binary Heap
a) Queue
b) Array
c) Stack
d) Linked List
a) Queue
b) Stack
c) Heap
d) Linked List
a) Array
b) Linked List
c) Binary Tree
d) Stack
a) log₂n
b) n
c) √n
d) n²
12. What is the maximum number of children a binary tree node can have?
a) 1
b) 2
c) 3
d) 4
14. Which operation is faster in a doubly linked list than a singly linked
list?
a) Insertion at beginning
b) Deletion from end
c) Searching
d) Traversing
a) 2^(h + 1) - 1
b) h
c) log₂h
d) h^2
a) Stack
b) Queue
c) Array
d) Recursion
a) Queue
b) Array
c) Stack
d) Graph
18. Which of these sorting algorithms has the best average case time
complexity?
a) Selection Sort
b) Bubble Sort
c) Merge Sort
d) Insertion Sort
a) Full
b) Empty
c) Half full
d) Invalid
a) Postorder traversal
b) Preorder traversal
c) Level order
d) Sorted output
23. What is the element of stack after the following stack operations?
PUSH(1), PUSH(2), POP(), PUSH(3), POP()?
a) 1
b) 2
c) 3
d) Empty
a) Stack
b) Queue
c) Tree
d) Hash table
a) Inorder
b) Postorder
c) Preorder
d) Level order
a) O(1)
b) O(log n)
c) O(n)
d) O(n²)
a) Array
b) Stack
c) Graph
d) Queue
a) Adjacency matrix
b) Adjacency list
c) Edge list
d) Binary Heap
a) Insertion at end
b) Insertion at front
c) Deletion from middle
d) Insertion at random index
a) Postorder
b) Inorder
c) Preorder
d) Level order
a) Insertion Sort
b) Selection Sort
c) Merge Sort
d) Bubble Sort
a) DFS
b) BFS
c) DLS
d) IDS
6. In a circular linked list, the last node points to:
a) NULL
b) Itself
c) First node
d) Middle node
7. Which tree has all levels fully filled except possibly the last level?
a) Data is deleted
b) Index is out of bounds
c) Two keys produce same hash index
d) Table is full
a) Stack
b) Tree
c) Queue
d) Array
a) 2h
b) 2^h
c) 2^(h+1) - 1
d) h²
11. Which of the following is not a characteristic of a heap?
12. Which data structure allows insertion and deletion from both ends?
a) Queue
b) Stack
c) Deque
d) Array
a) Queue
b) Stack
c) Array
d) Linked List
15. The time complexity of push and pop operations in stack is:
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
a) Maximum
b) Minimum
c) Middle value
d) None
18. What is the output of traversing a stack from bottom to top after
pushing 1, 2, 3?
a) 3 2 1
b) 1 2 3
c) 2 3 1
d) 1 3 2
a) Queue
b) Stack
c) Tree
d) Hash table
a) O(n log n)
b) O(n²)
c) O(n)
d) O(log n)
a) Queue
b) Heap
c) Stack
d) Array
a) Total nodes
b) Total leaves
c) Longest path from root to leaf
d) Number of children of root
a) O(1)
b) O(n)
c) O(log n)
d) O(n²)
a) Stack
b) Queue
c) Tree
d) Hash table
27. How many null pointers are in a binary tree with n nodes?
a) n
b) n - 1
c) n + 1
d) 2n
a) Insertion at front
b) Deletion from front
c) Insertion at end
d) Deletion from end
a) Array only
b) Linked list only
c) Either array or linked list
d) Queue
a) Postorder
b) Inorder
c) Preorder
d) BFS
SET-3
1.Which data structure is most suitable for implementing recursion
internally?
a) Queue
b) Stack
c) Heap
d) Tree
a) BFS
b) DFS
c) Dijkstra’s
d) Kruskal’s
3. Which of the following is not true about binary search trees (BSTs)?
a) Linear probing
b) Resizing table
c) Using linked lists
d) Using priority queues
a) Quick Sort
b) Bubble Sort
c) Linear Search
d) BFS
6. What is the worst-case complexity of inserting into a binary search tree?
a) O(log n)
b) O(1)
c) O(n)
d) O(n²)
7. Which data structure allows you to access the largest element in O(1)
time?
a) Stack
b) Queue
c) Max Heap
d) Binary Search Tree
a) Quick Sort
b) Merge Sort
c) Insertion Sort
d) Heap Sort
a) Fixed size
b) Insertion is costly
c) Direct access
d) Wastage of memory
a) Social networks
b) Maps and navigation
c) Network routing
d) All of the above
11. In postorder traversal, the sequence of visiting nodes is:
12. The number of edges in a complete undirected graph with n vertices is:
a) n
b) n(n-1)/2
c) n²
d) (n-1)²
13. The structure used for Breadth First Traversal of a graph is:
a) Stack
b) Queue
c) Tree
d) Array
a) Dijkstra’s
b) Floyd-Warshall
c) Kruskal’s
d) Bellman-Ford
a) Traversal
b) Access by index
c) Insertion at start
d) Insertion at end
16. A queue that allows insertion and deletion at both ends is called:
a) Priority Queue
b) Circular Queue
c) Deque
d) Double Queue
a) Inorder
b) Preorder
c) Postorder
d) Level order
a) DFS
b) BFS
c) Kruskal’s
d) Prim’s
a) Stack
b) Tree
c) Array
d) Linked List
a) Searching
b) Insertion
c) Deletion
d) Overflow checking
a) Unsorted array
b) Sorted array
c) Linked list
d) Tree only
23. The worst case for search in a hash table occurs when:
a) Array
b) Linked List
c) Stack using array
d) Queue using array
a) Queue
b) Stack
c) Tree
d) Graph
a) Memory leak
b) Out of memory error
c) Program crash
d) Deadlock
a) DAG
b) Tree
c) Spanning tree
d) Forest
SET-4
1. What is the main disadvantage of linked lists over arrays?
a) Inorder
b) Postorder
c) Preorder
d) Leftmost path
3. Which of the following is the most efficient when frequent insertions and
deletions occur in the middle of the list?
a) Array
b) Stack
c) Queue
d) Linked List
a) Stack
b) Tree
c) Queue
d) Hash Table
a) Stack
b) Queue
c) Binary Tree
d) Graph
a) DFS
b) BFS
c) Dijkstra
d) Bellman-Ford
a) Stack
b) Queue
c) Hash Table
d) Tree
a) l
b) 2^l
c) l²
d) 2^(l-1)
a) Merge Sort
b) Insertion Sort
c) Bubble Sort
d) Quick Sort
12. What is the primary advantage of AVL trees over regular BSTs?
a) Insertion is easier
b) Deletion is faster
c) Automatically balanced
d) Requires less space
a) n - 1
b) n
c) n + 1
d) 2n
a) Top = -1
b) Top = MaxSize
c) Top = 0
d) Stack is full
15. What is the maximum number of edges in a directed graph with n
vertices?
a) n(n-1)/2
b) n²
c) n(n-1)
d) 2n
a) O(n)
b) O(1)
c) O(log n)
d) O(n²)
19. Which tree traversal can be used to create a prefix expression from an
expression tree?
a) Preorder
b) Inorder
c) Postorder
d) Level Order
20. What is the output of this postfix expression? 5 3 2 * +
a) 16
b) 11
c) 10
d) 12
a) Graph
b) Tree
c) Stack
d) Queue
a) 14
b) 15
c) 13
d) 16
a) Hashing
b) Paging (uses arrays)
c) Stacks
d) Recursion
24. What is the main advantage of using a binary heap over a binary search
tree in a priority queue?
a) Faster search
b) Faster insertion
c) Faster deletion of min/max
d) Easy to implement
a) Linked list
b) Queue
c) Stack of stacks
d) Tree
a) Web crawling
b) Topological sorting
c) Memory allocation
d) Expression evaluation
28. A complete binary tree has how many nodes at level 2? (Assume root is
level 0)
a) 2
b) 3
c) 4
d) 1
29. What is the complexity of deleting an element from a hash table using
chaining?
a) O(1) average case
b) O(n) worst case
c) Both A and B
d) O(log n)
a) Inorder
b) Postorder
c) Preorder
d) Level order