Skip to content

Added Merge Sort algorithm in Python#1001

Open
Husnain-Ali-24 wants to merge 1 commit intoRishabh062:mainfrom
Husnain-Ali-24:add-merge-sort-python
Open

Added Merge Sort algorithm in Python#1001
Husnain-Ali-24 wants to merge 1 commit intoRishabh062:mainfrom
Husnain-Ali-24:add-merge-sort-python

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