How would you optimize a search algorithm to run efficiently on a mobile device with strict memory constraints?