Repository: TheAlgorithms/Python
Pull request: Merge sort Update variable names
Fixes #2023

Merge sort variable name updated along with some comments are added

Problem statement:
Mergesort Update Variable Names
I was looking over the mergesort.py file in the divide_and_conquer directory when I saw that all of the variable names are a single letter and there is not much documentation. Does anyone know enough about this file to improve the variable names and make the code more understandable?

Hints from issue discussion:
Can I improve the file?
No need to wait for permission.  Just go for it.  Pull requests will be reviewed.

Only our competitors think that we should wait.
Can I Modify the Variables to Clarify There Meanings ?
What I can do
Hello folks @Robinson-Arivan @aditya-190 @avitomar12, welcome to the community and before you contribute, please read our [CONTRIBUTION.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). It resolves most of the doubts you may have! You can go to the file and see if there's a problem as OP has noted. If you want to take the issue, remember to notify our community here as well to avoid conflicts.

Commit message: Update Merge sort variable names

Patch to review:
diff --git a/divide_and_conquer/mergesort.py b/divide_and_conquer/mergesort.py
index 328e3dca316f..51da8ba716e3 100644
--- a/divide_and_conquer/mergesort.py
+++ b/divide_and_conquer/mergesort.py
@@ -1,45 +1,48 @@
-def merge(a, b, m, e):
-    l = a[b : m + 1]  # noqa: E741
-    r = a[m + 1 : e + 1]
-    k = b
+def merge(arr, left, mid, right): 
+    # overall array will divided into 2 array
+    # l contain left portion of array from left to mid of array
+    # r contain right portion of array from mid+1 to till last of array
+    l = arr[left : mid + 1]  # noqa: E741
+    r = arr[mid + 1 : right + 1]
+    k = left
     i = 0
     j = 0
     while i < len(l) and j < len(r):
         # change sign for Descending order
         if l[i] < r[j]:
-            a[k] = l[i]
+            arr[k] = l[i]
             i += 1
         else:
-            a[k] = r[j]
+            arr[k] = r[j]
             j += 1
         k += 1
     while i < len(l):
-        a[k] = l[i]
+        arr[k] = l[i]
         i += 1
         k += 1
     while j < len(r):
-        a[k] = r[j]
+        arr[k] = r[j]
         j += 1
         k += 1
-    return a
+    return arr
 
 
-def mergesort(a, b, e):
+def mergesort(arr, left, right):
     """
     >>> 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 < e:
-        m = (b + e) // 2
+    if left < right:
+        mid = (left + right) // 2
         # print("ms1",a,b,m)
-        mergesort(a, b, m)
+        mergesort(arr, left, mid)
         # print("ms2",a,m+1,e)
-        mergesort(a, m + 1, e)
+        mergesort(arr, mid + 1, right)
         # print("m",a,b,m,e)
-        merge(a, b, m, e)
-        return a
+        merge(arr, left, mid, right)
+        return arr
 
 
 if __name__ == "__main__":


Code review comments:
diff_hunk: @@ -1,45 +1,48 @@
-def merge(a, b, m, e):
-    l = a[b : m + 1]  # noqa: E741
-    r = a[m + 1 : e + 1]
-    k = b
+def merge(arr, left, mid, right): 
+    # overall array will divided into 2 array
+    # l contain left portion of array from left to mid of array
+    # r contain right portion of array from mid+1 to till last of array
+    l = arr[left : mid + 1]  # noqa: E741
+    r = arr[mid + 1 : right + 1]
path: divide_and_conquer/mergesort.py
text: @user1:
Please change `l` to `new_left` and `r` to `new_right`.  The # noqa comment can also be removed.  Thanks!

@user1:
Or `left_arr` and `right_arr` might be better.

@author:
Hello @user1 sir, I have updated variable name. 
Please go through it.
Thanks!