Skip to content

zakelaskar/Math608-DataScienceProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฎ Python Sorting Analysis: TimSort vs PowerSort

This project was developed as part of the Math 608 - Data Science course. It explores the transition from TimSort to PowerSort in Python 3.11, explaining the underlying reasons, working mechanisms, and performance differences between the two sorting algorithms.


๐Ÿ“Œ Objective

To compare TimSort and PowerSort with a focus on:

  • Algorithm structure and internal steps
  • Edge-case performance
  • Time and space efficiency
  • Real-world relevance and application in Python

๐Ÿง  What Are TimSort and PowerSort?

TimSort

  • A hybrid sorting algorithm (Merge Sort + Insertion Sort)
  • Default in Python from version 2.3 to 3.10
  • Optimized for partially sorted data
  • Stable sort

PowerSort

  • Introduced in Python 3.11
  • Improved worst-case performance over TimSort
  • More consistent in edge-case behavior
  • Uses "power values" to determine merge order

๐Ÿ”ฌ Key Concepts Explained

  • Identifying Runs: Sub-sequences of ordered elements
  • Merge Rules: How runs are combined in each algorithm
  • Performance Analysis: On average and worst-case datasets
  • Python 3.11 Transition: Why the standard sorting method changed

๐Ÿ“Š Slide Highlights

  • Step-by-step simulation of sorting [5, 7, 8, 4, 2, 1, 3, 10, 12, 11, 9, 15]
  • Diagrams of merge stacks in TimSort
  • Power calculations and merge strategy in PowerSort
  • Summary tables comparing speed, space, and reliability

๐Ÿ“‚ Contents

Math608-DataScienceProject/
โ”‚
โ”œโ”€โ”€ Data Science Project.pptx         # Full slide deck
โ”œโ”€โ”€ README.md                         # Project documentation
๐Ÿ“ˆ Why Python Switched to PowerSort
More predictable behavior with irregular datasets

Lower memory usage

Tighter performance bounds

Alignment with CPythonโ€™s performance goals

๐Ÿ“œ License This project is for educational and research purposes. Please contact for reuse or collaboration.

๐Ÿ“ฌ Contact

Zakir Elaskar
๐Ÿ“ง zelaskar@csuchico.edu | elaskarzakir@gmail.com
๐Ÿ”— LinkedIn

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published