Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
20.3.4. Example of BFS Execution
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
5 cards from this lesson. Good the night before a test.
Try these first
- 1.
What does BFS stand for?
Hint
Think about how the search explores the graph.
- 2.
How do we keep track of vertices that have been visited in BFS?
Hint
Consider whether we need to revisit vertices.
- 3.
What is the main advantage of using a queue in BFS?
- To store vertices in a last-in
- first-out manner
- To manage which vertices to explore next in a first-in
- first-out manner
- To ignore vertices that have been visited
Hint
Think about how BFS needs to manage the order of exploration.
- 4.
The time complexity of BFS using an adjacency matrix is?
- O(n)
- O(n^2)
- O(n + m)
Hint
Consider how many entries are in the matrix for n vertices.
- 5.
Given the following graph composed of vertices and edges, write a BFS algorithm that starts with vertex 1 and outputs the order of vertices visited.
Hint
Consider how neighbors are added to the queue.
- 6.
Design a graph with 10 vertices and at least 8 edges such that BFS starting from vertex 1 visits vertices in the order of 1, 2, 3, 4, 5, .... Write what this order reveals about the graph's structure.
Hint
Visualize how each vertex connects and ensures every next vertex is reached during exploration.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
3 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
2 more questions available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting