Python-Scripts icon indicating copy to clipboard operation
Python-Scripts copied to clipboard

added counting sort

Open indshree opened this issue 7 months ago • 0 comments

PR Title

Added Counting Sort Algorithm in Python

Summary

Implemented the Counting Sort algorithm using a class-based approach in Python. The algorithm efficiently sorts non-negative integers by counting occurrences and using a cumulative sum approach.

Description

This PR introduces a CountingSort class that sorts an array using the Counting Sort algorithm. The algorithm is efficient for sorting numbers within a limited range.

The changes are as follows:

  • Implemented a class-based CountingSort algorithm
  • Ensured the sorting method works for non-negative and negative integers
  • Included a get_sorted_array() method to retrieve the sorted list
  • Added an example usage demonstrating the algorithm in action

Checks

In the repository

  • [x] Made no changes that degrade the functioning of the repository
  • [x] Gave each commit a better title (e.g., "Added Counting Sort Implementation")

In the PR

  • [x] Followed the format of the pull_request_template
  • [x] Made the Pull Request small and focused
  • [x] Tested the changes to ensure correctness

Thank You,
Shruti Shree

indshree avatar Mar 21 '25 16:03 indshree