Skip to content
Advertisement

Tag: search

First occurrence in a binary search

I’m tinkering with some code and I realized something I never knew. A normal binary search will return a random index in a data set for a key that occurs more than once. How can I modify this code below to return the first occurrence? Is this something people do? Answer Having found a matching value, you basically need to

Ultra-fast “Begins With” Query from Disk

I have a 40MB (too big for memory in this case) list of strings that I want to do “begins with” queries on to extract matches. Anyone know of a good data structure for this? Bonus points for an existing os java implementation. I would be willing to sacrifice “begins with” to just exact matching if something already exists. A

Advertisement