```
def f(x):
if(x==0):
return
else:
f(x-1)
print("this value has been removed from stack 1" ,x)
f(x-1)
print("this value has been removed from stack 2" ,x)
f(3)
```

output–

```
this value has been removed from stack 1 : 1
this value has been removed from stack 2 : 1
this value has been removed from stack 1 : 2
this value has been removed from stack 1 : 1
this value has been removed from stack 2 : 1
this value has been removed from stack 2 : 2
this value has been removed from stack 1 : 3
this value has been removed from stack 1 : 1
this value has been removed from stack 2 : 1
this value has been removed from stack 1 : 2
this value has been removed from stack 1 : 1
this value has been removed from stack 2 : 1
this value has been removed from stack 2 : 2
this value has been removed from stack 2 : 3
```

I am trying to implement merge sort algorithm.

In whole merge sort algorithm division of array is done using recursion.

```
def merge(arr1 , p1 , q1 , r1):
n1 = q-p+1
n2 = r-q
r[n2+1]
l[n1+1]
//merging r and l
def merge_sort(arr , p ,r):
if(p < r):
q = floor((p+r)/2)
merge_sort(arr ,p ,q)
merge_sort(arr , q+1 , r)
merge(arr p , q, r)
arr =[5,2,4,1]
merge_sort(arr , 0 , 3)
```

above multiple recursion is used.

how is it dividing the array using multiple recursion?