Data Structures · Question 5 · Easy

Which data structure is used to implement Breadth-First Search (BFS) of a graph?

  1. Stack
  2. Queue
  3. Binary search tree
  4. 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

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