3 ms·
What do you mean by "traverse them in parallel"? You want to find the medians of the two lists independently and then somehow combine them? How?
by yakubin 5y ago
What do you mean by "traverse them in parallel"? You want to find the medians of the two lists independently and then somehow combine them? How?
- Jtsummers 5y agoYou 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).