Why is the brute-force approach less ideal here?
Practice this question from Fenwick Tree - Binary Indexed Prefix Sum Pattern Practice Quiz, with options and an explanation.
Question
Why is the brute-force approach less ideal here?
Option A — Correct answer
Updating every later prefix value costs O(n).
Option B
It always uses no memory
Option C
It avoids all state changes
Option D
It only works for binary search
Explanation
Updating every later prefix value costs O(n).