Skip to content

Algorithms that put elements of a list in order.This Python application provides implementations of commonly used sorting algorithms: Merge Sort, Quick Sort, Insertion Sort, and Bubble Sort. These algorithms can be used to sort a list of elements in ascending or descending order.

Notifications You must be signed in to change notification settings

khotso-26/SortingAlgorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sorting Algorithms

This Python application provides implementations of commonly used sorting algorithms: Merge Sort, Quick Sort, Insertion Sort, and Bubble Sort. These algorithms can be used to sort a list of elements in ascending or descending order.

Algorithms Implemented

The following sorting algorithms are implemented in this application:

  • Merge Sort
  • Quick Sort
  • Insertion Sort
  • Bubble Sort

Usage

To use the sorting algorithms, follow these steps:

  1. Clone the repository or download the source code.
  2. Open the sorting_algorithms.py file in a Python IDE or editor.
  3. Modify the main function to customize the list of elements to be sorted.
  4. Choose the desired sorting algorithm by uncommenting the corresponding function call.
  5. Run the sorting_algorithms.py file.
  6. The sorted list will be displayed in the console output.

Note: You can modify the list of elements and the sorting algorithm based on your specific requirements.

Algorithm Details

Merge Sort Merge Sort is a divide-and-conquer algorithm that divides the input list into smaller sublists, sorts them recursively, and then merges them to produce a sorted output. It has a time complexity of O(n log n) in the average and worst case scenarios.

Quick Sort

Quick Sort is also a divide-and-conquer algorithm that partitions the input list into two sublists based on a chosen pivot element. It recursively sorts the sublists on either side of the pivot. Quick Sort has an average time complexity of O(n log n) but can degrade to O(n^2) in the worst case.

Insertion Sort

Insertion Sort is a simple comparison-based sorting algorithm that builds the final sorted list one element at a time. It iterates over the input list, comparing each element with the previous ones and placing it in the correct position. Insertion Sort has a time complexity of O(n^2) in the worst case but performs well for small lists.

Bubble Sort

Bubble Sort repeatedly swaps adjacent elements if they are in the wrong order until the entire list is sorted. It has a time complexity of O(n^2) in the worst case. Bubble Sort is straightforward to understand but less efficient compared to other sorting algorithms.

Contributing

Contributions are welcome! If you would like to contribute to this project, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes and push the branch to your fork.
  4. Submit a pull request with a description of your changes.

License

This project is licensed under the MIT License.

Feel free to customize the README file as per your specific application requirements and add any additional sections that might be relevant.

Happy sorting!

About

Algorithms that put elements of a list in order.This Python application provides implementations of commonly used sorting algorithms: Merge Sort, Quick Sort, Insertion Sort, and Bubble Sort. These algorithms can be used to sort a list of elements in ascending or descending order.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages