Skip to content
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

Add PagedMergeSort, a merge sort using O(√n) space #71

Merged
merged 49 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8a63108
Add PagedMergeSort
LSchwerdt Feb 5, 2023
e0ebe94
Update references
LSchwerdt Feb 7, 2023
0d4aa65
Return sorted vectors in sort!
LSchwerdt Feb 7, 2023
4d6e518
Make midpoint() backwards compatible
LSchwerdt Feb 7, 2023
58b06fb
Use PagedMergeSort when calling ThreadedPagedMergeSort in version < 1.3
LSchwerdt Feb 7, 2023
ce9ad62
Improve style
LSchwerdt Feb 10, 2023
66315f7
Add PagedMergeSort
LSchwerdt Feb 5, 2023
df33439
Update references
LSchwerdt Feb 7, 2023
b33b4e8
Return sorted vectors in sort!
LSchwerdt Feb 7, 2023
a5d5cea
Make midpoint() backwards compatible
LSchwerdt Feb 7, 2023
c2ff440
Use PagedMergeSort when calling ThreadedPagedMergeSort in version < 1.3
LSchwerdt Feb 7, 2023
2da1f83
Improve style
LSchwerdt Feb 10, 2023
d6f40db
Rebase and apply initial optimizations
LSchwerdt Feb 12, 2023
a25003e
Remove unused variable in function signatures
LSchwerdt Feb 12, 2023
88e5b22
Add algorithms to readme.md
LSchwerdt Feb 12, 2023
436eb79
Rename _midpoint to midpoint
LSchwerdt Feb 12, 2023
dad2a2c
Clarify comments in twoended_merge!
LSchwerdt Feb 12, 2023
cd72df0
Remove unnecessary @inbounds in twoended_merge!
LSchwerdt Feb 12, 2023
90c0ca6
Explain why twoended_merge! is used in comment
LSchwerdt Feb 12, 2023
7841b6a
Use midpoint instead of _midpoint
LSchwerdt Feb 12, 2023
2465073
Merge remote-tracking branch 'LSchwerdt/pagedmergesort' into pagedmer…
LSchwerdt Feb 12, 2023
dab157f
Fix stability of twoended_merge!
LSchwerdt Feb 12, 2023
ea4eb9a
Change function argument locations to match base.Sort
LSchwerdt Feb 12, 2023
d9fcaef
Fix midpoint calculation to always round down
LSchwerdt Feb 12, 2023
7b2a653
Make variable names and function signatures more consistent
LSchwerdt Feb 13, 2023
297348f
Add compat for StaticArrays
LSchwerdt Feb 14, 2023
b51c7ce
Improve documentation
LSchwerdt Feb 14, 2023
72a9550
Bump version number
LSchwerdt Feb 14, 2023
47722cc
Add extra tests for stable sorting algorithms
LSchwerdt Feb 14, 2023
256d1ff
Change extra tests to not use all presorted inputs
LSchwerdt Feb 14, 2023
a45a054
Simplify twoended_merge!
LSchwerdt Feb 16, 2023
f66e799
Use function for core merging loop
LSchwerdt Mar 19, 2023
bb4e706
Replace getNextBlock! macro by function
LSchwerdt Mar 22, 2023
0d9e23f
Reduce number of arguments of next_page!()
LSchwerdt Mar 22, 2023
cb89f11
Refactor page permutation
LSchwerdt Mar 23, 2023
5bcdbb8
Lilith's refactor
Apr 10, 2023
5dab2a1
Apply @LSchwerdt's suggestions
May 28, 2023
bfbe0cf
Merge pull request #1 from LilithHafner/pagedmergesort-lilith-refactor
LSchwerdt May 28, 2023
71fc310
Simplify check for input lengths in paged_merge!
LSchwerdt Aug 11, 2023
2c9ef24
Simplifcations
LSchwerdt Aug 11, 2023
4bbc185
Fix indentation
LSchwerdt Aug 11, 2023
3a8a53b
Remove superfluous check for small inputs in threaded_pagedmergesort!
LSchwerdt Aug 11, 2023
a783092
Improve formatting
LSchwerdt Aug 11, 2023
d3ea719
Remove ThreadedPagedMergesort
LSchwerdt Aug 12, 2023
3f337f0
Use the name "scratch" instead of "buf" or "t"
LSchwerdt Aug 12, 2023
56a609c
Merge branch 'master' into pagedmergesort
LilithHafner Aug 13, 2023
d2ea0a7
Use custom _unsafe_copyto! instead of copyto!
LSchwerdt Aug 14, 2023
717f9ae
Fix: pageLocations is initialized with a negative number of elements
LSchwerdt Aug 14, 2023
d367ee8
Add test for small input without initial optimizations
LSchwerdt Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SortingAlgorithms"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "1.1.0"
version = "1.1.1"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ The `SortingAlgorithms` package provides three sorting algorithms that can be us
- [HeapSort] – an unstable, general purpose, in-place, O(n log n) comparison sort that works by heapifying an array and repeatedly taking the maximal element from the heap.
- [TimSort] – a stable, general purpose, hybrid, O(n log n) comparison sort that adapts to different common patterns of partially ordered input data.
- [CombSort] – an unstable, general purpose, in-place, O(n log n) comparison sort with O(n^2) pathological cases that can attain good efficiency through SIMD instructions and instruction level paralellism on modern hardware.
- [PagedMergeSort] – a stable, general purpose, O(n log n) time and O(sqrt n) space comparison sort.
- [ThreadedPagedMergeSort] – a stable, general purpose, O(n log n) time and O(sqrt n) space comparison sort using multithreaded [parallel recursion].

[HeapSort]: https://en.wikipedia.org/wiki/Heapsort
[TimSort]: https://en.wikipedia.org/wiki/Timsort
[CombSort]: https://en.wikipedia.org/wiki/Comb_sort
[PagedMergeSort]: https://link.springer.com/chapter/10.1007/BFb0016253
[ThreadedPagedMergeSort]: https://link.springer.com/chapter/10.1007/BFb0016253
[parallel recursion]: https://en.wikipedia.org/wiki/Merge_sort#Merge_sort_with_parallel_recursion

## Usage

Expand Down
Binary file added docs/pagedMerge_130_130.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading