The Following Function Represents Which Sortingp Pre Langc #840
The following function represents which sorting?</p> <pre><code class="language-c"> void Sorting(int a[], int n) { bool swap = true; int first = 0; int last = n - 1; while (swap) { swap = false; for (int i = first; i < last;i++) { if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); swap = true; } } if (!swap) break; swap = false; --last; for (int i = last - 1; i >= first; i--) { if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); swap = true; } } ++first; } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Sorting - Cocktail Sort - Quiz No.2.
The following function represents which sorting?
void Sorting(int a[], int n) { bool swap = true; int first = 0; int last = n - 1; while (swap) { swap = false; for (int i = first; i < last;i++) { if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); swap = true; } } if (!swap) break; swap = false; --last; for (int i = last - 1; i >= first; i--) { if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); swap = true; } } ++first; } }
Bubble sort
Selection sort
Bidirectional bubble sort
Odd-even sort
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes