Re: Can Binary Search Be Improved with Threading
- From: Marco Manfredini <ok_nospam_ok@xxxxxxxxx>
- Date: Sun, 18 Nov 2007 01:57:49 +0100
jehugaleahsa@xxxxxxxxx wrote:
Hello:
My boss suggested that he could write a faster binary search than I
could by creating a new thread and searching the data on each half on
the range. In other words, he would create a new thread to check the
other half of the range. I am assuming this is a binary search that
operates on contigious memory like an array, C++ vector, etc or in a
binary search tree.
Now, I thought this was rediculous but I kept it to myself. My
coworkers aren't trained programmers or Computer Scientists. As I saw
it, every time you split the list, you already know which way to go,
so why would you create a thread to check the other side? The overhead
of the thread is overkill, and one of the threads will always lead to
a dead end (it also destroys the invariant).
Am I in the wrong here, or is my boss' suggestion just plain wrong?
Maybe two threads, thread-0 searches the even indices, thread-1 the odd?
Shouldn't be too impressive. Binary search is O(log_2(n)), two threads have each O(log_2(n/2)) = O(log_2(n)-1). For twice the energy consumed this is a brouhaha.
In theory, you could take M processors to split the array up into M+1 search segments. If the processors are tightly coupled they would decide in each step which segment contains the result and jump onto it etc. That way you get O(log(n)/log(M+1)) if you can avoid the synchronization overhead.
.
- References:
- Can Binary Search Be Improved with Threading
- From: jehugaleahsa@xxxxxxxxx
- Can Binary Search Be Improved with Threading
- Prev by Date: Re: Can Binary Search Be Improved with Threading
- Next by Date: Re: two interesting data structure/algorithm questions
- Previous by thread: Re: Can Binary Search Be Improved with Threading
- Index(es):
Relevant Pages
|