4 ms·
Bad question. What is better when searching in an unsorted array - linear search or sorting and binary search? Assuming better implies faster only the size of t
by danbruc 14y ago
Bad question. What is better when searching in an unsorted array - linear search or sorting and binary search? Assuming better implies faster only the size of the array and the (expected) number of searches matters.
If you want me to figure out if searching an array is the best option in the first place, then ask me that question. It is an important skill to ask questions - especially when you have to figure out what customers really need versus what they have requested - but expecting that a simple interview question with extremely narrow scope like this makes me question if an array is the correct choice is ridiculous.
It's a bit like when your math test asks you to calculate some annual interests for you savings account and you start to question if bringing money to a bank is the best option in the first place.