Merge Sort Implementation in Python

Switch to Dreamhost, and we will move your web site. No kidding.

Today I post the python implementation of merge sort. This is straight-forward implementation of the algorithm presented in the book Introduction to Algorithms [CLRS]. If you think the implementation can be more Pythonic, feel free to comment.

Here is my code:

def merge(li, start, mid, end):
left_li = []
left_li.extend(li[start : mid+1])
right_li = []
right_li.extend(li[mid+1: end+1])
i = 0
j = 0
for k in range(start, end+1):

A historical timeline of Codango™

Original Source

#codango #developer #development #coder #coding

We're happy to share this resource that we found. The content displayed on this page is property of it's original author and/or their organization.


Leave a Reply

Your email address will not be published. Required fields are marked *