List ordered push: search from back if lower than pivot#693
Merged
therault merged 1 commit intoICLDisco:masterfrom Nov 1, 2024
Merged
List ordered push: search from back if lower than pivot#693therault merged 1 commit intoICLDisco:masterfrom
therault merged 1 commit intoICLDisco:masterfrom
Conversation
bosilca
approved these changes
Nov 1, 2024
Determine a pivot point (mid point of priority range) and search from front or back depending on where the new item lies. Inserting elements with highest or lowest priority becomes a constant operation and elements within the current range will on average be O(N/2). This assumes a linear distribution of priorities. For non-linear distributions the insertion will be skewed to either front or back but and the worst case will be O(N) but average complexity would still be closer to O(N/2) and we win in cases of highest and lowest priorities. Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
2be9718 to
2740a14
Compare
Contributor
Author
|
Force-pushed a small correction: use |
therault
approved these changes
Nov 1, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Determine a pivot point (mid point of priority range) and search from front or back depending on where the new item lies. Inserting elements with highest or lowest priority becomes a constant operation and elements within the current range will on average be O(N/2).
This works best with linear distribution of priorities. For non-linear distributions the insertion will be skewed to either front or back but and the worst case will still be O(N). Average complexity would still be closer to O(N/2) and insertion with highest and lowest priorities will still be O(1).