Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

What is a global industry?

Answered: 1 week ago

Question

Question Can I collect benefits if I become disabled?

Answered: 1 week ago

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago