Practice
1. What is the time complexity of the forward pass of batch normalization for a dataset with n samples and d features?
easy
Solution
Step 1: Analyze the operations
Batch normalization involves computing mean and variance, both O(n * d) operations.Step 2: Consider the normalization step
Normalizing each feature is also O(n * d).Final Answer:
Option D -> Option DQuick Check:
Batch norm: O(n * d) for mean/variance [OK]
Hint: Batch norm: O(n * d) for mean/variance [OK]
Common Mistakes:
2. What is the time complexity of computing the ROC curve using the sklearn library?
easy
Solution
Step 1: Understand ROC computation
ROC curve computation involves sorting the scores, which is O(n log n).Step 2: Eliminate wrong options
O(n^2) is incorrect as it suggests quadratic complexity, O(n) suggests linear complexity which ignores sorting, and O(log n) is too low.Final Answer:
Option A -> Option AQuick Check:
ROC curve involves sorting, hence O(n log n) [OK]
Hint: ROC curve involves sorting, hence O(n log n) [OK]
Common Mistakes:
3. You implemented a KNN classifier using a KD-Tree, but it returns incorrect classifications. What is the most likely cause?
medium
Solution
Step 1: Identify potential issues
Incorrect classifications often stem from using an inappropriate distance metric.Step 2: Eliminate other options
A: Balancing affects efficiency, not correctness. C: Insufficient data affects accuracy, not correctness. D: High-dimensionality affects efficiency, not correctness.Final Answer:
Option A -> Option AQuick Check:
Check distance metric for KD-Tree issues [OK]
Hint: Check distance metric for KD-Tree issues [OK]
Common Mistakes:
4. In a text classification task using Multinomial Naive Bayes, which preprocessing step is crucial for improving model performance?
medium
Solution
Step 1: Understand text preprocessing needs
In text classification, irrelevant words can add noise.Step 2: Evaluate preprocessing steps
Removing stop words (Removing stop words) reduces noise and improves performance. Options A and C are less relevant as MultinomialNB doesn't require normalized or scaled features. Applying PCA for dimensionality reduction is unnecessary as PCA isn't typically used for text data.Final Answer:
Option C -> Option CQuick Check:
Remove stop words to reduce noise in text data. [OK]
Hint: Remove stop words to reduce noise in text data. [OK]
Common Mistakes:
5. How can you optimize a naive 2D convolution implementation for large images and kernels?
hard
Solution
Step 1: Identify optimization techniques
Using FFT can significantly reduce the computational complexity of convolution from O(N^2 * K^2) to O(N^2 log N) for large images and kernels.Step 2: Eliminate wrong options
Use a larger stride to reduce computation. reduces output size, not computation. Increase the kernel size to cover more area. increases computation. Use a smaller kernel to decrease computation. limits kernel effectiveness.Final Answer:
Option C -> Option CQuick Check:
FFT reduces convolution complexity. [OK]
Hint: FFT reduces convolution complexity. [OK]
Common Mistakes:
