Releases: Moon42Dev/PySort
Release list
1.1.2
PySort 1.1.2 Release Notes
Introduction
We are excited to announce the release of PySort 1.1.2, a minor update focused on enhancing the functionality and reliability of the package. This release includes bug fixes for the test folder and introduces new step-by-step print functions for each sorting algorithm. These improvements aim to make PySort more user-friendly and robust for developers and learners.
Bug Fixes
Test Folder Bugs
- Resolved issues with the test cases that were causing incorrect test results.
- Improved the stability and accuracy of the tests, ensuring they correctly validate the sorting algorithms.
- Enhanced test coverage to include edge cases and ensure comprehensive testing of all sorting functions.
New Features
Step-by-Step Print Functions
We have added new step-by-step print functions to each sorting algorithm. These functions allow users to see the state of the array after each significant step in the sorting process. This feature is handy for educational purposes, enabling users to understand better how each algorithm works.
Example Usage
Here's how you can use the new features:
Bubble Sort with Step-by-Step Printing
from PySort.bubble_sort import bubble_sort
arr = [64, 34, 25, 12, 22, 11, 90]
bubble_sort(arr)In this example, bubble_sort will print the state of the array at each step of the sorting process.
Counting Sort
from PySort.counting_sort import counting_sort
arr = [4, 2, 2, 8, 3, 3, 1]
sorted_arr = counting_sort(arr)
print("Sorted array:", sorted_arr)Installation
You can install or update PySort via pip:
pip install --upgrade PySort1.1.0
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 PySortIf 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.
1.0.0
PySort 1.0.0 Release Notes
Introduction
We are excited to announce the release of PySort 1.0.0, a comprehensive Python package that offers easy access to a variety of sorting algorithms. PySort is designed for both educational purposes and practical use in projects requiring sorting functionality. This initial release includes implementations of the most common sorting algorithms, complete with thorough documentation and testing.
Features
PySort 1.0.0 includes the following sorting algorithms:
- Bubble Sort: A simple comparison-based algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
- Insertion Sort: A simple and efficient algorithm for small datasets that builds the sorted array one item at a time.
- Merge Sort: A stable, comparison-based, divide-and-conquer sorting algorithm that is efficient for large datasets.
- Quick Sort: A highly efficient sorting algorithm using a divide and conquer approach, ideal for most datasets.
- Selection Sort: An in-place comparison sorting algorithm that is easy to understand and implement.
- Radix Sort: A non-comparative sorting algorithm that processes individual digits and is efficient for fixed-size integer datasets.
Installation
You can install PySort via pip:
pip install PySortIf you have the source code, you can install the package using the setup script:
git clone https://github.com/yourusername/PySort.git
cd PySort
pip installUsage
Using PySort is straightforward. Here is an example of how to utilize the sorting algorithms:
from PySort import bubble_sort, insertion_sort, merge_sort, quick_sort, selection_sort, radix_sort
arr = [64, 34, 25, 12, 22, 11, 90]
print("Original array:", arr)
print("Bubble Sort:", bubble_sort(arr.copy()))
print("Insertion Sort:", insertion_sort(arr.copy()))
print("Merge Sort:", merge_sort(arr.copy()))
print("Quick Sort:", quick_sort(arr.copy()))
print("Selection Sort:", selection_sort(arr.copy()))
print("Radix Sort:", radix_sort(arr.copy()))Algorithm Details
- Bubble Sort
Bubble Sort is a simple algorithm that compares each pair of adjacent elements and swaps them if they are in the wrong order. This process is repeated until no more swaps are needed, which means the list is sorted. Although it is simple to implement, it is unsuitable for large data sets due to its O(n^2) time complexity.
- Insertion Sort
Insertion Sort builds the final sorted array one item at a time. It takes each element from the list and inserts it into the correct position in the already sorted part of the list. It is efficient for small data sets or nearly sorted lists but has an O(n^2) time complexity in the average and worst cases.
- Merge Sort
Merge Sort is a divide-and-conquer algorithm that divides the list into two halves, recursively sorts each half, and then merges the sorted halves. It has a time complexity of O(n log n) and is stable, making it suitable for large data sets. However, it requires additional space for merging, which can be a disadvantage.
- Quick Sort
Quick Sort is another divide-and-conquer algorithm. It selects a 'pivot' element and partitions the array into two halves such that elements less than the pivot are on the left and elements greater than the pivot are on the right. It then recursively sorts the sub-arrays. Quick Sort has an average time complexity of O(n log n) but can degrade to O(n^2) in the worst case. However, it is often faster in practice and does not require additional memory.
- Selection Sort
Selection Sort repeatedly selects the smallest element from the unsorted portion of the list and moves it to the sorted portion. It has an O(n^2) time complexity, making it inefficient for large data sets. However, it is easy to implement and understand.
- Radix Sort
Radix Sort is a non-comparative sorting algorithm that sorts numbers by processing individual digits. It distributes elements into buckets according to their radix and processes each digit from the least significant to the most important. It has a time complexity of O(d(n + k)), where d is the number of digits and k is the range of the digits. Radix Sort is efficient for sorting numbers with a fixed number of digits.