Why is the brute-force approach less ideal here?

Practice this question from Shortest Path in Unweighted Graph - BFS Distance Pattern Practice Quiz, with options and an explanation.

Question

Why is the brute-force approach less ideal here?

Option A — Correct answer

DFS may explore long paths before shorter paths.

Option B

It is always constant time

Option C

It avoids graph traversal entirely

Option D

It works only on sorted arrays

Explanation

DFS may explore long paths before shorter paths.

Shortest Path in Unweighted Graph - BFS Distance Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker