Data Structures & AlgorithmsHardProduct Company SDE · Fenwick round
Problem: What is the complexity of computing the number of inversions using a Fenwick tree over n distinct values?
- A. O(n^2)
- B. O(n log n)
- C. O(n)
- D. O(n sqrt n)
Correct answer: B. O(n log n)
Each element costs one Fenwick query and one update, each O(log n).
More Coding Interview Problems questions
- Problem: Which operation is the bottleneck of the naive recursive Fibonacci algorithm?
- Problem: What is the worst-case complexity of Heapsort on n elements?
- Problem: What is the property of a 'Monge' matrix that enables fast DP optimisation?
- Problem: Which problem is classically solved by the 'convex hull trick' in DP with linear functions?
- Problem: What is the cost of inserting into a binary search tree that is perfectly balanced with n nodes?
- Problem: Which concept explains why the smallest enclosing circle is determined by at most three boundary points?