adspace


wap for bubble sort

Answer Posted / sachin

n=No of elements in an array;

for(i=0;i<n;i++)
{for(j=0;j<n-i;j++)
{if(arr[j]>arr[j+1])
swap(arr[j],arr[j+1]);
}
}

void swap(int*x, int*y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}

Is This Answer Correct ?    7 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category