Because O(1) is the average case, not the worst. In the worst case, many keys hashing to the same bucket, a hash lookup degrades to O(n) (you scan a long chain or probe sequence), and a resize/rehash can be even worse. Hard-real-time code, especially an interrupt handler, is bounded by worst-case execution time (WCET), not average, so an operation that's usually fast but occasionally O(n) can blow the timing budget and cause a missed deadline. In that context you prefer a structure with a bounded worst case, a fixed-size direct-mapped table, a sorted array with O(log n) binary search, or a small linear scan whose worst case you can actually compute. The average-case win of hashing is irrelevant if the worst case is what determines whether you meet your deadline.
Data Structures & Algorithms · Interview question
A hash table is "O(1) lookup." Why might you still not use one in an ISR?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Time & Space Complexity
Big-O describes how cost grows with input size, and on an MCU you also care about the constants it hides, worst-case determinism (WCET), and the space-time tradeoff.