Skip to content

1.1.0

Choose a tag to compare

@Moon42Dev Moon42Dev released this 28 Jun 17:30
· 2 commits to main since this release
09518b9

PySort 1.1.0 Release Notes

Introduction

We are pleased to announce the release of PySort 1.1.0, an enhanced version of our comprehensive Python package for sorting algorithms. This release adds three new sorting algorithms: Heap Sort, Shell Sort, and Comb Sort. These additions provide more options for efficient sorting and improve the overall functionality of the package.

New Features

Heap Sort

Heap Sort is an efficient comparison-based sorting algorithm that uses a binary heap data structure. It has a time complexity of O(n log n), making it suitable for large datasets. The algorithm works by building a max heap and then repeatedly extracting the maximum element from the heap and rebuilding the heap until all elements are sorted.

Shell Sort

Shell Sort is an in-place comparison-based sorting algorithm. It generalizes insertion sort by comparing elements far apart, reducing the number of swaps needed. It is efficient for medium-sized datasets and works well in practice with an average time complexity of O(n log n).

Comb Sort

Comb Sort is an improvement over Bubble Sort. It eliminates turtles, or small values near the end of the list, by using a larger gap size. The gap size is reduced in each iteration based on a shrink factor. Comb Sort improves on Bubble Sort with a time complexity of O(n^2 / 2^p), where p is the number of increments.

Installation

You can install PySort via pip:

pip install PySort

If you have the source code, you can install the package using the setup script:

git clone https://github.com/Moon42Dev/PySort.git
cd PySort
pip install .

Usage

Using PySort is straightforward. Here is an example of how to utilize the new sorting algorithms:

from PySort import heap_sort, shell_sort, comb_sort

arr = [64, 34, 25, 12, 22, 11, 90]

print("Original array:", arr)
print("Heap Sort:", heap_sort(arr.copy()))
print("Shell Sort:", shell_sort(arr.copy()))
print("Comb Sort:", comb_sort(arr.copy()))

Algorithm Details

Heap Sort

Heap Sort builds a max heap from the input data and then repeatedly extracts the maximum element from the heap, rebuilding the heap until all elements are sorted. It has an O(n log n) time complexity and is an efficient sorting algorithm for large datasets.

Shell Sort

Shell Sort sorts elements far apart from each other to reduce the number of swaps. It starts with a large gap and reduces the gap in each iteration. The average time complexity is O(n log n), making it efficient for medium-sized datasets.

Comb Sort

Comb Sort improves on Bubble Sort by eliminating turtles, or small values near the end of the list, using a larger gap size. The gap size is reduced in each iteration using a shrink factor. Comb Sort has a time complexity of O(n^2 / 2^p), making it faster than Bubble Sort in practice.