Giter VIP home page Giter VIP logo

khotso-26 / sortingalgorithms Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 12 KB

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.

Python 100.00%
python sorting-algorithms bubblesort insertionsort mergesort quicksort selectsort

sortingalgorithms's Introduction

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.