Write programs for Bubble Sort, Quick sort

Answer Posted / srinivsa

void bubbleSort(int numbers[], int array_size)
{
int i, j, temp;

for (i = (array_size - 1); i >= 0; i--)
{
for (j = 1; j <= i; j++)
{
if (numbers[j-1] > numbers[j])
{
temp = numbers[j-1];
numbers[j-1] = numbers[j];
numbers[j] = temp;
}
}
}
}

Is This Answer Correct ?    57 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to find 3rd element from end in a linked list in one pass?

629


Traverse the given tree using Inorder, Preorder and Postorder traversals. Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A

848


Why would we use dynamically allocated arrays vs vectors?

600


Define heap order property?

706


Why do we need sorting?

617


What do you mean by structure property in a heap?

723


Is arraylist a collection?

678


In what order the elements of a hashset are retrieved?

703


What are the pre-requisite for the collection to perform binary search?

685


What is a vector element?

667


What is array traversing?

664


What is difference between list and linked list?

717


What do you mean by primary clustering?

747


how to display Singly Linked List from First to Last?

626


How does a selection sort work for an array?

684