Skip to content

An efficient implementation of Timsort in Python

Notifications You must be signed in to change notification settings

LMouhssine/Timsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

An efficient implementation of Timsort in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages