Bubble sort while loop

Pls explain how a while loop is used in bubble sort.

Hey @vashishthkuntal.gajjar2019

while loop is used to keep track of how many time swapping iteration needs to be done
So see if array is
a b c then we will need 2 iterations of swapping once from a to c then a to b

So while loop is keeping check of that

DO a dry run on small example and u will better understand it :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.