-
Notifications
You must be signed in to change notification settings - Fork 468
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
Adding Parallel Binary Search module #3859
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mighty fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rewrite everything since most of it doesn't really make sense to me right now (a lot of grammatical issues), and the explanations are incomplete and can be more elaborated, especially for someone who doesn't know the topic.
## Tutorial | ||
This technique is usually used when we can solve a single query by doing linear or binary search on monotonic function. | ||
|
||
The trick is doing it offline, sort queries by their median (initially $l$, $r$ will be the binary search values), do linear search, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trick is doing it offline, sort queries by their median (initially $l$, $r$ will be the binary search values), do linear search, | |
The trick is doing it offline, sorting queries by their median (initially $l$, $r$ will be the binary search values), linearly searching |
This technique is usually used when we can solve a single query by doing linear or binary search on monotonic function. | ||
|
||
The trick is doing it offline, sort queries by their median (initially $l$, $r$ will be the binary search values), do linear search, | ||
whenever you find a query its median in same as your position in linear search, check the monotonic function, and do same as binary search (edit either $l$ or $r$). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenever you find a query its median in same as your position in linear search, check the monotonic function, and do same as binary search (edit either $l$ or $r$). | |
whenever you find a query its median in same as your position in linear search, checking the monotonic function, and binary searching (edit either $l$ or $r$). |
The trick is doing it offline, sort queries by their median (initially $l$, $r$ will be the binary search values), do linear search, | ||
whenever you find a query its median in same as your position in linear search, check the monotonic function, and do same as binary search (edit either $l$ or $r$). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's what you meant, then resolve those changes. If not, then please rewrite that sentence since it doesn't really make sense right now.
The trick is doing it offline, sort queries by their median (initially $l$, $r$ will be the binary search values), do linear search, | ||
whenever you find a query its median in same as your position in linear search, check the monotonic function, and do same as binary search (edit either $l$ or $r$). | ||
|
||
You will need to do the linear search $O(\log_2{N})$ times, so $l = r$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite this... It sounds weird
|
||
You will need to do the linear search $O(\log_2{N})$ times, so $l = r$. | ||
|
||
Usually the complexity would be: $O((N+Q) \cdot \log_2{(N+Q)}^2)$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incomplete thought. Usually it's that time complexity but you should also state the time complexity of the parallel binary search following a ", but"
<FocusProblem problem="sam" /> | ||
|
||
## Solution - New Roads Queries | ||
We can see that connectivity of the nodes is a monotonic function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How
We can see that connectivity of the nodes is a monotonic function. | ||
|
||
Now let's use parallel binary search: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine these sentences in some way
|
||
When sweeping through the array of edges, union them in the DSU. | ||
|
||
Whenever there is a query with median = $i$, if the two nodes where connected in DSU, it means the answer is $\leq i$ ($r = i$), otherwise it means $\gt i$ ($l = i+1$). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split this into two sentences since it's too wordy and grammatically incorrect
|
||
<FocusProblem problem="sam" /> | ||
|
||
## Solution - New Roads Queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely expand on this solution
This pull request has been automatically marked as stale because it has not had recent activity. Please address the requested changes and re-request reviews. Thank you for your contribution! |
Changes requested have not been made. Free free to create a new PR. |
Place an "x" in the corresponding checkbox if it is done or does not apply to this pull request.
I did this pull request because the previous one was closed by stale (#3777 )