dsa
dsa
dsa
a) Tree
b) Graph
c) Stack
d) Hash Table
Answer: c) Stack
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: a) O(1)
a) O(n)
b) O(n log n)
c) O(1)
d) O(log n)
Answer: c) O(1)
a) Queue
b) Stack
c) Array
d) Linked List
Answer: b) Stack
• What is the minimum number of nodes in a complete binary tree with depth d?
a) 2^d - 1
b) 2^(d+1) - 1
c) 2^(d-1)
d) d
Answer: a) 2^d – 1
• In a circular linked list, how do you make a node the new head?
a) Bubble Sort
b) Quick Sort
c) Heap Sort
d) Merge Sort
Answer: d) Merge Sort
a) Insertion
b) Deletion
c) Heapify
d) Bubble up
Answer: c) Heapify
A. Allocate memory
B. Update the head pointer
C. Assign data to the node
D. Connect the new node with other nodes
Answer: B) Update the head pointer
• What is the time complexity for inserting an element at the end of a singly linked
list if a pointer to the last node is maintained?
A) O(1)
B) O(n)
C) O(log n)
D) O(n log n)
Answer: A) O(1)
• What is the average time complexity for searching an element in a linked list?
A) O(1)
B) O(log n)
C) O(n)
D) O(n^2)
Answer: C) O(n)
A) Stack
B) Array
C) Linked List
D) Both B and C
Answer: D) Both B and C
• What is the main advantage of a doubly linked list over a singly linked list?
C) Easier to implement
D) Deleting a node
Answer: D) Deleting a node
• In an AVL tree, what is the maximum height difference between the left and right
subtrees of any node?
A) 1
B) 2
C) 3
D) 4
Answer: A) 1
A) 5
B) 4
C) 6
D) 7
Answer: A) 5
A) Inorder
B) Preorder
C) Postorder
D) Level order
Answer: D) Level order
A) Queue
B) Stack
C) Priority Queue
D) Array
Answer: B) Stack
C) Heap operations
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A) O(1)
A) O(n)
B) O(log n)
C) O(1)
D) O(n log n)
Answer: A) O(n)
• In which data structure is insertion performed at the rear and deletion at the front?
A) Stack
B) Queue
C) Linked List
D) Tree
Answer: B) Queue
• Which of the following sorting algorithms has a time complexity of O(n^2) in its
average case?
A) Quick Sort
B) Merge Sort
C) Selection Sort
D) Counting Sort
Answer: C) Selection Sort
A) 0
B) n - 1
C) n
D) 2n - 1
Answer: B) n - 1
A) The left subtree of a node contains only nodes with values less than the node’s key
B) The right subtree of a node contains only nodes with values greater than or equal to the
node’s key
C) Both left and right subtrees are also binary search trees
• In a directed acyclic graph (DAG), which algorithm is used to find the topological
order?
A) Dijkstra’s Algorithm
B) BFS
C) Topological Sort
D) DFS
Answer: C) Topological Sort
A) Stack
B) Queue
C) Graph
D) Disjoint Set
Answer: D) Disjoint Set
• Which of the following algorithms does not use divide and conquer?
A) Merge Sort
B) Quick Sort
C) Binary Search
D) Selection Sort
Answer: D) Selection Sort
• What is the time complexity of enqueue and dequeue operations in a queue
implemented with a linked list?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A) O(1)
A) O(log n)
B) O(n)
C) O(n log n)
D) O(1)
Answer: A) O(log n)
• Which data structure is suitable for applications involving Last-In, First-Out (LIFO)
operations?
A) Stack
B) Queue
C) Deque
D) Tree
Answer: A) Stack
• Which sorting algorithm is suitable for sorting data with a small range of integer
values?
A) Merge Sort
B) Heap Sort
C) Counting Sort
D) Quick Sort
Answer: C) Counting Sort
B) Leaf node
C) Internal node
D) Parent node
Answer: B) Leaf node
A) Queue
B) Stack
C) Priority Queue
D) Array
Answer: B) Stack
A) Rehashing
B) Chaining
C) Linear Probing
• What is the time complexity for removing an element from a doubly linked list?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A) O(1)
• Which of the following graph traversal algorithms can find the shortest path in an
unweighted graph?
A) DFS
B) BFS
C) Dijkstra's Algorithm
D) Kruskal's Algorithm
Answer: B) BFS
A) Queue
B) Stack
C) Priority Queue
D) Array
Answer: B) Stack
• Which algorithm is the most efficient for finding the shortest path in a weighted
graph?
A) BFS
B) DFS
C) Dijkstra's Algorithm
D) Prim’s Algorithm
Answer: C) Dijkstra's Algorithm
A) Root
B) Left child
C) Right child
B) AVL Tree
C) Max-Heap
D) Red-Black Tree
Answer: B) AVL Tree
• Which sorting algorithm has the best time complexity in the average case for a large
dataset?
A) Quick Sort
B) Bubble Sort
C) Insertion Sort
D) Selection Sort
Answer: A) Quick Sort
• What is the time complexity of inserting a node in a binary search tree with n nodes?
A) O(log n)
B) O(n)
C) O(n log n)
D) O(1)
Answer: A) O(log n)
A) Queue
B) Stack
C) Hash Table
D) Graph
Answer: B) Stack
A) O(1)
B) O(log n)
C) O(n)
D) O(n^2)
Answer: C) O(n)
A) Inorder
B) Preorder
C) Postorder
D) Level order
Answer: D) Level order
A) Large dataset
B) Small dataset
C) Random dataset
• What is the minimum time complexity for deleting a node from a linked list with n
nodes?
A) O(1)
B) O(log n)
C) O(n)
D) O(n log n)
Answer: A) O(1)
a) Leaf node
b) Root node
c) Right-most node
d) Left-most node
Answer: b) Root node
a) Bubble Sort
b) Counting Sort
c) Radix Sort
d) Floyd-Warshall
Answer: d) Floyd-Warshall
a) Queue
b) Stack
c) Linked List
d) Tree
Answer: b) Stack
• Which sorting algorithm is known for being the fastest for small datasets?
a) Quick Sort
b) Bubble Sort
c) Insertion Sort
d) Selection Sort
Answer: c) Insertion Sort
• In a binary search tree, what is the time complexity for finding the minimum or
maximum element?
a) O(1)
b) O(log n)
c) O(n)
d) O(n log n)
Answer: b) O(log n)
a) Fixed size
b) Better memory utilization
c) Simpler implementation
d) Allows random access
Answer: b) Better memory utilization
a) O(n)
b) O(log n)
c) O(n log n)
d) O(n^2)
Answer: C) O(n log n)