Question.2
A firmware engineer has a sorted lookup table of 256 calibration values. He needs to find the closest match for an ADC reading in an ISR that fires at 10 kHz. Which search method should he use?
Select Answer
Linear search — simpler code, easier to debug
Binary search — O(log n) guarantees completion in ≤ 8 comparisons for 256 elements
Hash table — O(1) lookup is fastest
Both A and B give the same performance for 256 elements