2 ms·
You have two indices, one for each list, updated separately. Iterate through a lost until it’s next element is larger than the current element in the other list
by Jtsummers 5y ago
You have two indices, one for each list, updated separately. Iterate through a lost until it’s next element is larger than the current element in the other list. Iterate through it until the same condition. Keep going until your present position is at the halfway point, the you’ve got your median.
They don’t mean parallel like two thread, though you could use two coroutines or a similar mechanism.
- yakubin 5y agoThanks. That makes sense. The "in parallel" certainly threw me off. Although in the article the author at some point switches from lists to vectors, which changes the whole task, and allows for a more efficient implementation (even if it's an answer to a different question).