Skip to content

Latest commit

 

History

History
56 lines (35 loc) · 1.64 KB

README.md

File metadata and controls

56 lines (35 loc) · 1.64 KB

Advanced Timsort Implementation in Python

This repository contains an efficient implementation of the Timsort algorithm in Python. Timsort is a hybrid sorting algorithm derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data.

Features

  • Efficient implementation of Timsort
  • Demonstrates advanced Python concepts
  • Includes example usage and performance testing

Installation

Clone this repository to your local machine:

git clone https://github.com/LMouhssine/Timsort.git
cd Timsort

Usage

To use the Timsort implementation in your project, import the timsort function from timsort.py:

from timsort import timsort

# Example usage
arr = [64, 34, 25, 12, 22, 11, 90]
sorted_arr = timsort(arr)
print(sorted_arr)

Performance

Timsort has a time complexity of O(n log n) in the worst and average cases, and O(n) in the best case. It is designed to take advantage of partial ordering in the input data, making it particularly efficient for real-world datasets.

Running Tests

To run the unit tests, execute the following command in the project directory:

python -m unittest test_timsort.py

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License and Usage Rights

This project is currently provided without a specific license. All rights are reserved by the project owner. If you wish to use, modify, or distribute this code, please contact the project owner for permission.

Acknowledgments

  • Tim Peters for creating the Timsort algorithm
  • Python Software Foundation for incorporating Timsort into Python's standard library