A hybrid bifurcated sorting algorithm using ascending and descending linked lists with BST-accelerated insertion
Project description
bifurcated_sort
A hybrid sorting algorithm that splits the input into two linked lists (ascending and descending), processes non-fitting elements using a BST-assisted insertion strategy, and merges both lists to produce the final sorted output.
📄 Full documentation and detailed walkthrough:
https://balajisuresh1359.github.io/balaji-area/code/bifurcated_insertion_sort.html
Installation
pip install bifurcated_sort
Example Usage
from bifurcated_sort import bfc_sort, bfc_sorted
arr = [15, 3, 8, 1, 12, 6]
bfc_sort(arr)
print(arr)
# Output: [1, 3, 6, 8, 12, 15]
result = bfc_sort([5, 2, 8], inplace=False, reverse=True)
result
# Output: [8, 5, 2]
arr2 = [2, 1, 32]
result = bfc_sorted(arr)
result
# Output: [1, 2, 32] # inplace false by default
arr2
# Output: [2, 1, 32]
Benchmark (20,000 random integers)
# Output:
# bfc_sort time: 0.026061058044433594
# sorted() time: 0.001425027847290039
Complexity
- Time Complexity:
- Best case: O(n)
- Average case: O(n log n) to O(n√n)
- Worst case: O(n²)
- Space Complexity: O(n)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bifurcated_sort-0.2.0.tar.gz.
File metadata
- Download URL: bifurcated_sort-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63faf0809f5303e9ee899524b4b5c4b1f6e4ee45ffb91ccfa0a4688528fe9896
|
|
| MD5 |
9d108c3abd0e21c3a9e5c77da4e47c07
|
|
| BLAKE2b-256 |
d583e347b8359d7e45937b20dfdb79c88026b8526bc28496ca17b70a4bc3d62c
|
File details
Details for the file bifurcated_sort-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bifurcated_sort-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4a3f68a6d90ecbcb3a6edb1bd6f26b14299867b6f4e88a610df4bd8947ee3a0
|
|
| MD5 |
c0115a9a17c4fd90de1f071a710c3afe
|
|
| BLAKE2b-256 |
50112adfd82ea333cb54338631544dfdf4bab721a0b5ef5e4235daa323a89ddd
|