Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Merge Sort algorithm in Python #1001

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Husnain-Ali-24
Copy link

Description of Changes:
Added a Python implementation of the Merge Sort algorithm in mergesort.py. This algorithm sorts an array by dividing it into two halves, recursively sorting each half, and then merging the sorted halves together.

Problem Statement:
Implement the Merge Sort algorithm to sort a list of numbers in ascending order.

Algorithm Details:

  • Complexity:
    • Time Complexity: (O(n \log n)), where (n) is the number of elements in the list. This complexity holds for both average and worst cases.
    • Space Complexity: (O(n)), due to the auxiliary space used for merging.
  • Explanation:
    • The list is divided into two halves recursively until each sublist has a single element.
    • The sorted sublists are then merged back together to form a single sorted list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant