Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions regarding the binary search example #291

Open
rohanrayan opened this issue Jun 5, 2024 · 0 comments
Open

Questions regarding the binary search example #291

rohanrayan opened this issue Jun 5, 2024 · 0 comments

Comments

@rohanrayan
Copy link

rohanrayan commented Jun 5, 2024

Hi

Thanks for the book. Its very interesting.

I have one question regarding the binary search example that you have. The way you optimize further (after making it branchless and using prefetching) is to reorder it in an entzynger array. But since this is an O(n) operation anyway on the array, what is the point? We can as well search for the element while constructing the heap structure right? I dont see the need to do this and then do a binary search (albeit efficient) after that.

So to me it looks like you have introduced an additional O(n) operation to make the O(log n) operation faster, which doesnt make sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant