Skip to main content

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

# In-place sorting
arr = [15, 3, 8, 1, 12, 6]
bfc_sort(arr)
print(arr)
# Output: [1, 3, 6, 8, 12, 15]

# Return a new reversed sorted list (does not modify the original)
result = bfc_sort([5, 2, 8], inplace=False, reverse=True)
result
# Output: [8, 5, 2]

# Using bfc_sorted (always returns a new list)
arr2 = [2, 1, 32]
result = bfc_sorted(arr2)
result
# Output: [1, 2, 32]   # inplace=False by default

arr2
# Output: [2, 1, 32]   # original list remains unchanged

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bifurcated_sort-0.2.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bifurcated_sort-0.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file bifurcated_sort-0.2.1.tar.gz.

File metadata

  • Download URL: bifurcated_sort-0.2.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for bifurcated_sort-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bd1fd3704c613421e4017c5d46d8d40c4224659097d9ad6bf3e7eab1c97ce42f
MD5 462a051c114aac5a0146f48c5b696a90
BLAKE2b-256 f3d0fc642114c2f56f07aea531c9b54de3555a18f4591f0a1606a3e807cbc4d0

See more details on using hashes here.

File details

Details for the file bifurcated_sort-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bifurcated_sort-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 85e5bbc4f0aa784f8b717fdac8a38f3b4f1bf5b00c4b1ae25280f22677b9d340
MD5 161d384894ee978f07981466fc4fb2b3
BLAKE2b-256 1f2740204ef1b0b6fb9b122ac93cebe34e03f196405e1f4c05c66884d4a47ff1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page