Why is the brute-force approach less ideal here?

Practice this question from Search a 2D Matrix - Flattened Binary Search Pattern Practice Quiz, with options and an explanation.

Question

Why is the brute-force approach less ideal here?

Option A — Correct answer

Scanning every cell costs O(rows * cols).

Option B

It is always O(1)

Option C

It avoids all comparisons

Option D

It only works for binary trees

Explanation

Scanning every cell costs O(rows * cols).

Search a 2D Matrix - Flattened Binary Search Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker