Data Structures · Question 5 · Easy
Which data structure is used to implement Breadth-First Search (BFS) of a graph?
- Stack
- Queue
- Binary search tree
- Hash table
Answer and explanation
Answer: B. Queue
Explanation: BFS visits vertices level by level, which needs First-In-First-Out order, so a queue is used. DFS uses a stack (or recursion).
Previous: What is the time complexity of accessing the element at index i of an array? · Next: An inorder traversal of a Binary Search Tree (BST) lists the keys in which…
Practise data structures
Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.
More data structures questions
- Starting with an empty stack, Kavya performs: push(5), push(8), push(3)…
- Starting with an empty queue: enqueue(A), enqueue(B), enqueue(C), dequeue()…
- What is the time complexity of accessing the element at index i of an array?
- An inorder traversal of a Binary Search Tree (BST) lists the keys in which…
- What is the postfix form of the infix expression A + B * C - D ?
- A binary tree has height 4, where height is the number of edges on the longest…
- What is the value of the postfix expression 6 2 3 + - 3 8 2 / + * ?
- A circular queue is implemented in an array of size n using front and rear…
- Keys 15, 22, 8 and 29 are inserted in that order into an empty hash table of…
- The preorder traversal of a Binary Search Tree is 50, 30, 20, 40, 70, 60, 80…
More technical & programming practice
Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge