0% found this document useful (0 votes)
6 views24 pages

Data Structures Mcq 1

The document contains a series of questions and answers related to data structures and algorithms, covering topics such as time complexity, traversal methods, and data structure characteristics. It includes multiple-choice questions about linked lists, stacks, queues, trees, and hashing techniques. The questions aim to assess knowledge on the efficiency and application of various data structures 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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views24 pages

Data Structures Mcq 1

The document contains a series of questions and answers related to data structures and algorithms, covering topics such as time complexity, traversal methods, and data structure characteristics. It includes multiple-choice questions about linked lists, stacks, queues, trees, and hashing techniques. The questions aim to assess knowledge on the efficiency and application of various data structures 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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

SET-1

1. What is the time complexity to insert an element at the beginning of a


linked list?

a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)

2. Which data structure uses LIFO (Last In, First Out)?

a) Queue
b) Stack
c) Array
d) Linked List

3. What is the time complexity to access an element in an array by index?

a) O(1)
b) O(n)
c) O(log n)
d) O(n log n)

4. What is the best case time complexity of linear search?

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

6. Which traversal method is used in depth-first traversal of a tree?

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

8. Which data structure is used to implement recursion?

a) Queue
b) Array
c) Stack
d) Linked List

9. Which data structure is best for implementing priority queues?

a) Queue
b) Stack
c) Heap
d) Linked List

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

a) Array
b) Linked List
c) Binary Tree
d) Stack

11. What is the height of a complete binary tree with n nodes?

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

13. Which hashing technique handles collisions by storing all elements in a


list at a location?
a) Linear probing
b) Quadratic probing
c) Chaining
d) Rehashing

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

15. A full binary tree of height h has how many nodes?

a) 2^(h + 1) - 1
b) h
c) log₂h
d) h^2

16. Which of the following is used in Breadth-First Search (BFS)?

a) Stack
b) Queue
c) Array
d) Recursion

17. Which structure is used to convert infix to postfix expression?

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

19. What is the degree of a leaf node?


a) 1
b) 0
c) 2
d) Depends on tree

20. What does a hash function do?

a) Converts data into a tree


b) Searches for duplicates
c) Maps data to a unique index
d) Encrypts data

21. In a circular queue, when front == rear, the queue is:

a) Full
b) Empty
c) Half full
d) Invalid

22. The inorder traversal of a binary search tree gives:

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

24. Which structure is ideal for implementing undo/redo operations?

a) Stack
b) Queue
c) Tree
d) Hash table

25. What does the term “enqueue” refer to?


a) Removing from queue
b) Adding to stack
c) Adding to queue
d) Removing from stack

26. In which traversal is the root node visited first?

a) Inorder
b) Postorder
c) Preorder
d) Level order

27. What is the auxiliary space complexity of Merge Sort?

a) O(1)
b) O(log n)
c) O(n)
d) O(n²)

28. Which of the following is a non-linear data structure?

a) Array
b) Stack
c) Graph
d) Queue

29. Which of these is not used in graph representations?

a) Adjacency matrix
b) Adjacency list
c) Edge list
d) Binary Heap

30. What is a leaf node in a tree?

a) A node with no children


b) A node with two children
c) Root node
d) None of the above
SET-2

1. What is the primary use of a stack in function calls?

a) To store local variables


b) To store the return address
c) To execute loops
d) To call constructors

2. Which of the following operations is not supported by arrays?

a) Insertion at end
b) Insertion at front
c) Deletion from middle
d) Insertion at random index

3. Which traversal is used to convert a binary expression tree into prefix


expression?

a) Postorder
b) Inorder
c) Preorder
d) Level order

4. Which algorithm is based on the divide-and-conquer paradigm?

a) Insertion Sort
b) Selection Sort
c) Merge Sort
d) Bubble Sort

5. Which is leastly used graph traversal algorithm?

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) Full Binary Tree


b) Complete Binary Tree
c) Perfect Binary Tree
d) AVL Tree

8. A hash collision occurs when:

a) Data is deleted
b) Index is out of bounds
c) Two keys produce same hash index
d) Table is full

9. Which of these is a non-linear data structure?

a) Stack
b) Tree
c) Queue
d) Array

10. What is the maximum number of nodes in a binary tree of height h?

a) 2h
b) 2^h
c) 2^(h+1) - 1
d) h²
11. Which of the following is not a characteristic of a heap?

a) Complete binary tree


b) Can be used to implement priority queue
c) Always balanced
d) Sorted order

12. Which data structure allows insertion and deletion from both ends?

a) Queue
b) Stack
c) Deque
d) Array

13. The best data structure to check for balanced parentheses in an


expression is:

a) Queue
b) Stack
c) Array
d) Linked List

14. A binary tree is balanced if:

a) All nodes have two children


b) Every level is full
c) Left and right subtrees differ in height by -1,0,1
d) It is complete

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)

16. Which of the following is NOT a type of linked list?


a) Single
b) Double
c) Triple
d) Circular

17. In a min-heap, the root node is:

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

19. Which data structure is most suitable for implementing undo


functionality?

a) Queue
b) Stack
c) Tree
d) Hash table

20. The key difference between BFS and DFS is:

a) One uses stack, other uses queue


b) Both use stack
c) Both use recursion
d) BFS visits leaves first
21. What is the worst-case time complexity of quicksort?

a) O(n log n)
b) O(n²)
c) O(n)
d) O(log n)

22. Which of the following can be used to implement a priority queue?

a) Queue
b) Heap
c) Stack
d) Array

23. What does ‘depth’ in a tree represent?

a) Total nodes
b) Total leaves
c) Longest path from root to leaf
d) Number of children of root

24. What is the space complexity of recursive factorial function?

a) O(1)
b) O(n)
c) O(log n)
d) O(n²)

25. Which data structure is best for checking palindromes?

a) Stack
b) Queue
c) Tree
d) Hash table

26. When does rehashing occur in a hash table?


a) When collision occurs
b) When table becomes too full
c) When search fails
d) When deletion happens

27. How many null pointers are in a binary tree with n nodes?

a) n
b) n - 1
c) n + 1
d) 2n

28. Which operation is not efficient in singly linked list?

a) Insertion at front
b) Deletion from front
c) Insertion at end
d) Deletion from end

29. Stack can be implemented using:

a) Array only
b) Linked list only
c) Either array or linked list
d) Queue

30. Which tree traversal is used to create a copy of a tree?

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

2. Which algorithm uses backtracking and a stack for its execution in


graphs?

a) BFS
b) DFS
c) Dijkstra’s
d) Kruskal’s

3. Which of the following is not true about binary search trees (BSTs)?

a) Left subtree contains values less than root


b) Right subtree contains values greater than root
c) Can contain duplicate values
d) All leaves must be at the same level

4. A hash table with chaining handles collisions by:

a) Linear probing
b) Resizing table
c) Using linked lists
d) Using priority queues

5. Which of these is an example of divide-and-conquer algorithm?

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

8. Which sorting algorithm is best suited for nearly sorted data?

a) Quick Sort
b) Merge Sort
c) Insertion Sort
d) Heap Sort

9. Which of the following is not a limitation of array data structure?

a) Fixed size
b) Insertion is costly
c) Direct access
d) Wastage of memory

10. Which of the following applications use graph data structure?

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:

a) Left → Right → Root


b) Root → Left → Right
c) Right → Left → Root
d) Root → Right → Left

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

14. Which algorithm finds the minimum spanning tree in a graph?

a) Dijkstra’s
b) Floyd-Warshall
c) Kruskal’s
d) Bellman-Ford

15. Which of the following operations is the most expensive in an array?

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

17. Which traversal is useful to evaluate an expression tree?

a) Inorder
b) Preorder
c) Postorder
d) Level order

18. Which of the following algorithms is used to detect a cycle in a graph?

a) DFS
b) BFS
c) Kruskal’s
d) Prim’s

19. A binary heap is typically implemented using:

a) Stack
b) Tree
c) Array
d) Linked List

20. Which operation is faster in a circular queue than in a linear queue?

a) Searching
b) Insertion
c) Deletion
d) Overflow checking

21. What is the purpose of a sentinel node in linked list?


a) To store extra data
b) To mark start and end
c) To act as a dummy node
d) To increase memory

22. In which case does binary search work?

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) Keys are unique


b) Table is empty
c) All keys collide
d) Table is full

24. Which of the following statements about trees is false?

a) A tree with n nodes has exactly n–1 edges


b) A binary tree is a special case of tree
c) Trees can have cycles
d) Tree is a connected acyclic graph

25. Which of the following uses dynamic memory allocation?

a) Array
b) Linked List
c) Stack using array
d) Queue using array

26. Which data structure is best suited for implementing undo-redo in


editors?
a) Queue
b) Stack of stacks
c) Tree
d) Graph

27. In BFS traversal of a graph, a node is visited:

a) Before all its adjacent nodes


b) After visiting all adjacent nodes
c) In random order
d) Only if not visited earlier

28. Which data structure is commonly used in compiler syntax checking?

a) Queue
b) Stack
c) Tree
d) Graph

29. What is the result of stack overflow?

a) Memory leak
b) Out of memory error
c) Program crash
d) Deadlock

30. A graph that has no cycles and is connected is called a:

a) DAG
b) Tree
c) Spanning tree
d) Forest

SET-4
1. What is the main disadvantage of linked lists over arrays?

a) Memory usage is more efficient


b) Requires dynamic allocation
c) Random access is not possible
d) All elements are stored consecutively

2. Which traversal method is used to find the minimum value in a Binary


Search Tree?

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

4. Which of these data structures is ideal for job scheduling in operating


systems?

a) Stack
b) Tree
c) Queue
d) Hash Table

5. Which operation has a time complexity of O(1) in a stack implemented


using arrays?
a) Pop
b) Push
c) Peek
d) All of the above

6. Which of the following uses level-order traversal?

a) Stack
b) Queue
c) Binary Tree
d) Graph

7. In graph theory, which traversal technique guarantees the shortest path


(unweighted)?

a) DFS
b) BFS
c) Dijkstra
d) Bellman-Ford

8. Which is the most suitable data structure for implementing a dictionary?

a) Stack
b) Queue
c) Hash Table
d) Tree

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

a) l
b) 2^l
c) l²
d) 2^(l-1)

10. In which scenario does linear probing fail in hashing?


a) When the table is full
b) When there's a duplicate key
c) When load factor < 1
d) Never fails

11. Which sorting technique is not stable by default?

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

13. In a binary tree, the number of null links is always:

a) n - 1
b) n
c) n + 1
d) 2n

14. In an array-based stack implementation, what indicates stack


underflow?

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

16. What does a complete graph mean?

a) Each node has only one edge


b) All nodes are connected
c) No node is connected
d) Acyclic graph

17. Which of the following is true about doubly linked lists?

a) Each node has one pointer


b) Insertion is difficult
c) Traversal is possible in both directions
d) Uses less memory than array

18. What is the space complexity of BFS traversal?

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

21. Which data structure is best for evaluating mathematical expressions?

a) Graph
b) Tree
c) Stack
d) Queue

22. How many edges are there in a tree with 15 nodes?

a) 14
b) 15
c) 13
d) 16

23. Which of the following is used in memory management in operating


systems?

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

25. Which data structure is the best to implement multi-level undo?

a) Linked list
b) Queue
c) Stack of stacks
d) Tree

26. In a full binary tree, the number of leaf nodes is:

a) One more than internal nodes


b) Half of total nodes
c) Same as internal nodes
d) Always odd

27. A directed acyclic graph (DAG) is used in:

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)

30. Which of the following traversals yields post-fix notation?

a) Inorder
b) Postorder
c) Preorder
d) Level order

You might also like