Practice
1. What is the time complexity of calculating the mean Average Precision (mAP) for a single image with N predicted bounding boxes and M ground truth boxes?
easy
Solution
Step 1: Understand the Process
For each predicted box, IoU is calculated with each ground truth box, leading to N * M comparisons.Step 2: Determine Complexity
Each comparison is constant time, so the overall complexity is O(N * M).Final Answer:
Option C -> Option CQuick Check:
IoU comparisons drive complexity [OK]
Hint: IoU comparisons drive complexity [OK]
Common Mistakes:
2. What is the time complexity of generating a sinusoidal positional encoding matrix of size
position x d_model?easy
Solution
Step 1: Analyze the operations
The code iterates over each position and each dimension, performing constant-time operations.Step 2: Eliminate wrong options
O(position^2) is incorrect because the complexity is not quadratic in position. O(d_model^2) is incorrect because the complexity is not quadratic in d_model. O(1) is incorrect because the complexity is not constant.Final Answer:
Option C -> Option CQuick Check:
Iterate over position and dimension. [OK]
Hint: Iterate over position and dimension. [OK]
Common Mistakes:
3. What is the time complexity of computing the scaled dot-product attention for a single query with n keys?
easy
Solution
Step 1: Identify operations
For a single query, the main operations are dot product and softmax, both O(n).Step 2: Eliminate incorrect complexities
O(n^2) and O(n log n) are incorrect as they imply more complex operations than present.Final Answer:
Option C -> Option CQuick Check:
Single query, n keys -> O(n) [OK]
Hint: Single query, n keys -> O(n) [OK]
Common Mistakes:
4. In a recommendation system, why might you choose cosine similarity over Euclidean distance?
medium
Solution
Step 1: Compare properties
Cosine similarity measures angle, not magnitude, making it invariant to vector length.Step 2: Eliminate incorrect reasons
Cosine similarity isn't inherently faster (A), doesn't handle missing data better (C), and interpretability is subjective (D).Final Answer:
Option A -> Option AQuick Check:
Cosine ignores magnitude, focuses on direction. [OK]
Hint: Cosine ignores magnitude, focuses on direction. [OK]
Common Mistakes:
5. How can you optimize a KD-Tree implementation for a KNN classifier to handle large datasets more efficiently?
hard
Solution
Step 1: Identify optimization strategies
Approximate nearest neighbors can significantly speed up queries in large datasets.Step 2: Evaluate other options
A: Balancing helps but isn't enough for large datasets. B: Increasing dimensions worsens performance. D: Reducing data points isn't always feasible.Final Answer:
Option B -> Option BQuick Check:
Approximate neighbors speed up KD-Tree [OK]
Hint: Approximate neighbors speed up KD-Tree [OK]
Common Mistakes:
