- Linear search faster than binary search - 1 Update
| "Öö Tiib" <ootiib@hot.ee>: Jan 08 06:00PM -0800 On Saturday, 8 January 2022 at 05:15:34 UTC+2, Bonita Montero wrote: > > For one, you binary search version does not attamtp to take advantage > > of a possible "lucky hit". ... > Show me the code where a "lucky hit" is sufficient. It is hard to read your code as it is random slice of real thing. That is perhaps why you can't write lucky code. Ok ... code: constexpr auto YEAR = DAY * 365; size_t lucky_hit = (tsCalc * 12) / YEAR; One multiplication, one division and we have "lucky_hit". Now the homework for you is to verify if it is precisely the month index or is next to it. |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment