Coding Interview Pattern 4: Recursive Call
Jan 13, 2025
In Merge Sort, recursion is used to divide the array into smaller parts.
Get Lake22’s stories in your inbox
Join Medium for free to get updates from this writer.
Pattern 4a — Recursive
- Merge Sort: The array is recursively divided into two halves, and then the halves are merged together in sorted order.
Common Pattern
def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2
left = arr[:mid]
right = arr[mid:]
merge_sort(left)
merge_sort(right)
# Merge stepPattern 4b — Dividing or Comparing Elements:
Merge Sort: Divides the array into two halves and recursively sorts them.



