Expert
Algorithmic Optimization
Refactor inefficient code to optimize for time and space complexity.
📝 Contenido del prompt
Review the following unoptimized pseudocode for a search function. Identify the time complexity using Big O notation and rewrite the algorithm to improve efficiency to O(log n). Additionally, discuss the trade-offs regarding memory usage and readability introduced by your optimization.