排序演算法 pdqsort, timsort

我對演算法沒啥 sense,但是看到些相關對基礎(應該說基石)的改良增強,覺得很有趣。 這種演算法的在效能與空間上的改進並且被各主流平台語言接受,我猜大概是幾年一遇吧, 懂演算法又能做改良的人真是了不起! Golang 將會在下一版(v1.19?)把預設的排序改為 pdqsort (Pattern-defeating Quicksort 也就是 Quicksort 改良版) 在這個commit 提到 Across all benchmarks, pdqsort is never significantly slower than the previous algorithm. In common patterns, pdqsort is often faster (i.e. 10x faster in sorted slices). The pdqsort is described at https://arxiv.org/pdf/2106.05123.pdf This CL is inspired by both C++ implementation and Rust implementation. C++ implementation: https://github.com/orlp/pdqsort Rust implementation: https://docs.rs/pdqsort/latest/pdqsort/ Timsort,hybrid stable sorting algorithm( merge sort 跟 insertion sort 的結合版)...

2022-05-06 · 1 分鐘 · Randy IN tech