Practice
Solution
Step 1: Analyze entropy calculation
Entropy calculation involves counting occurrences and computing probabilities, both O(n).Step 2: Eliminate wrong options
O(n^2) and O(n log n) are incorrect as they overestimate the operations needed.Final Answer:
Option D -> Option DQuick Check:
Entropy calculation is linear in n [OK]
Solution
Step 1: Consider class imbalance
Stratified K-Fold ensures each fold has the same class distribution as the entire dataset.Step 2: Eliminate wrong options
Standard K-Fold and D do not preserve class distribution. Leave-One-Out is inefficient for large datasets.Final Answer:
Option A -> Option AQuick Check:
Use Stratified K-Fold for class balance. [OK]
Solution
Step 1: Identify Feature Types
Numerical features benefit from scaling, while categorical features require encoding.Step 2: Choose Appropriate Methods
Min-Max scaling is suitable for numerical features, and one-hot encoding is standard for categorical features.Final Answer:
Option B -> Option BQuick Check:
Scale numerical, encode categorical. [OK]
Solution
Step 1: Identify memory bottlenecks
Intermediate results can consume significant memory.Step 2: Optimize memory usage
In-place operations reduce memory overhead by modifying data directly.Final Answer:
Option A -> Option AQuick Check:
In-place operations save memory [OK]
Solution
Step 1: Identify Bottlenecks
Calculating log values repeatedly can be computationally expensive.Step 2: Optimize Calculation
Precomputing log values for positions reduces redundant calculations.Final Answer:
Option C -> Option CQuick Check:
Precompute logs for efficiency. [OK]
