From b6cc37d461da2a631fe077d0cf952c5981d2dfdd Mon Sep 17 00:00:00 2001 From: Jigyasa G Date: Thu, 10 Oct 2019 00:42:09 +0530 Subject: [PATCH] mergesort added (#1313) * mergesort added * added doctest --- divide_and_conquer/mergesort.py | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 divide_and_conquer/mergesort.py diff --git a/divide_and_conquer/mergesort.py b/divide_and_conquer/mergesort.py new file mode 100644 index 000000000..b2a5a4c32 --- /dev/null +++ b/divide_and_conquer/mergesort.py @@ -0,0 +1,45 @@ +def merge(a,b,m,e): + l=a[b:m+1] + r=a[m+1:e+1] + k=b + i=0 + j=0 + while i>> mergesort([3,2,1],0,2) + [1, 2, 3] + >>> mergesort([3,2,1,0,1,2,3,5,4],0,8) + [0, 1, 1, 2, 2, 3, 3, 4, 5] + """ + if b