I wrote this bubble sort algorithm after watching CPP-Recursion Sort Video. Even though this is the same code as shown in the video still, I am not getting the answer. Segmentation fault is coming.
Here, n is size of array, and j is initially 0 when the function in called.
void bubbleSort2(int arr[],int n,int j){
if(n==1)
return ;
if(j==n-1)
bubbleSort2(arr,n-1,0);
if(arr[j+1]<arr[j])
swap(arr[j+1],arr[j]);
bubbleSort2(arr,n,j+1);
return;
}