An array given Arr[] which is in decreasing order. How many swapping required in
for(int index=0;index
{
for(int j=n-index;j
{
if(a[j]>a[j+1])
{
swap(a[j],a[j+1]);
}
}
}
An array given Arr[] which is in decreasing order. How many swapping required in
for(int index=0;index
{
for(int j=n-index;j
{
if(a[j]>a[j+1])
{
swap(a[j],a[j+1]);
}
}
}
Welcome to the forum rahulietlko!
<puts on my Drill Instructor hat>
"Do I look like a computer, to you?"
"On this planet, we expect the computer programs to do the mundane counting, for us, not the other way around"
"Now get back to that program, add a counter variable, and let the program do the counting!
"The raw recruits we get here at the Marine Depot Training Center - you would not believe."
P.S. And use code tags around your program, next time, by clicking on the # icon, inside the advanced reply window. Right at the top, just right of top dead center.
<Returns D.I. hat to place of honor>