Question: In this code: /* This program sorts the array elements in the ascending order using bubble sort method */ #include int const N = 6

 In this code: /* This program sorts the array elements in

In this code:

/* This program sorts the array elements in the ascending order using bubble sort method */ #include int const N = 6 void BubbleSort(int [ ], int); // function prototyping int main() { int A[N]={77,42,35,12,101,6}; //You can also get values from user for the array. int i; cout A[K+1] ) { hold =A[K]; A[i]=A[K+1]; A[K+1]=hold; Swapped =true; } K++; } If( ! Swapped ) break; // no swap occurred in previous pass } }

AIM: Write a program to Sort values in Ascending / Increasing Order using Bubble Sort Technique in Linear Array: Description: Sorting refers to the operation of re-arrangements of values in Ascending or Descending order of the Linear Array A Here 'A' is Linear Array and N is the number of values stored in A. Algorithm: (Bubble Sort) BUBBLE (A, N) Here A is an Array with N elements stored in it. This algorithm sorts the elements in A. 1. Repeat Steps 2 to 4 for Pass = 1 to N-1 2. Set Swapped = 0 and K = 0 3. Repeat while k A[ K + 1) then Interchange A[ K] and A[ K + 1 ) and Set Swapped = 1 [End of if structure. ] (b) Set K = K + 1 [ End of inner loop of step-3. ] 4. if Swapped = 0 then break the outer loop of step-1 [ End of outer loop of step-1. ] 5. End

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!