Practice
1. What is the time complexity of a single iteration of gradient descent for linear regression with n samples and d features?
easy
Solution
Step 1: Identify operations in a single iteration
Each iteration involves matrix multiplication and gradient computation.Step 2: Calculate complexity
Matrix multiplication and gradient computation both require O(nd) operations.Final Answer:
Option C -> Option CQuick Check:
Matrix operations scale with samples and features. [OK]
Hint: Matrix operations scale with samples and features. [OK]
Common Mistakes:
2. What is the time complexity of calculating DCG for a list of n relevance scores?
easy
Solution
Step 1: Analyze the DCG Calculation
DCG involves iterating over the list once and performing constant-time operations for each element.Step 2: Determine Complexity
Since each element is processed once, the complexity is O(n).Final Answer:
Option A -> Option AQuick Check:
DCG iterates once over n elements. [OK]
Hint: DCG iterates once over n elements. [OK]
Common Mistakes:
3. You implemented early stopping in your training loop, but the model still overfits. What is the most likely reason?
medium
Solution
Step 1: Analyze early stopping behavior
Early stopping relies on validation performance to halt training.Step 2: Identify the root cause of overfitting
If the validation set is too small, it may not accurately reflect generalization, leading to overfitting despite early stopping.Final Answer:
Option A -> Option AQuick Check:
Small validation set can mislead early stopping. [OK]
Hint: Small validation set can mislead early stopping. [OK]
Common Mistakes:
4. 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:
5. How can you optimize the memory usage of a Random Forest implementation with bagging and feature sampling?
hard
Solution
Step 1: Identify Memory Optimization Techniques
Using smaller data types can significantly reduce memory usage.Step 2: Evaluate Options
Using a single tree (A) reduces model complexity, not memory; reducing features (B) affects accuracy; serialization (D) affects storage, not runtime memory.Final Answer:
Option B -> Option BQuick Check:
Smaller data types save memory [OK]
Hint: Smaller data types save memory [OK]
Common Mistakes:
