This Sorting algorithm has O(n^2) time complexity.
-> first iterate though a given array(i as a looping variable)
->secondly run a second nested loop (j as a looping variable)
-> check(arr[j]>=arr[j+1]) then swap(arr[j],arr[j+1])
This Sorting algorithm has O(n^2) time complexity.
In this sorting we basically make a gap such that the smallest element to the adjacent will occupy that place:
1.
for example: 6->5->7->3->2
for i=1: first=5
while(A[j]>=5) we make a gap in the 1st place i.e. 6 so 6->5 will become 5->6
Similarly this process go on: