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.