Which Of The Following Function Correctly Represents Oddeven #979
Which of the following function correctly represents odd-even sort?
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 - Odd-Even Sort - Quiz No.2.
Which of the following function correctly represents odd-even sort?
void oddEvenSort(int arr[], int n) { bool Sorted = false; while (!Sorted) { Sorted = true; for (int i=1; i<n-2; i=i+2) { if (arr[i] > arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } for (int i=0; i<n-2; i=i+2) { if (arr[i] > arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } } return; }
void oddEvenSort(int arr[], int n) { bool Sorted = false; while (!Sorted) { Sorted = true; for (int i=1; i<n-1; i=i+2) { if (arr[i] > arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } for (int i=0; i<n-1; i=i+2) { if (arr[i] > arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } } return; }
void oddEvenSort(int arr[], int n) { bool Sorted = false; while (!Sorted) { Sorted = true; for (int i=1; i<n-1; i=i+2) { if (arr[i] < arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = true; } } for (int i=0; i<n-1; i=i+2) { if (arr[i] < arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = true; } } } return; }
void oddEvenSort(int arr[], int n) { bool Sorted = false; while (!Sorted) { Sorted = true; for (int i=1; i<n-1; i=i+1) { if (arr[i] < arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } for (int i=0; i<n-1; i=i+1) { if (arr[i] < arr[i+1]) { swap(arr[i], arr[i+1]); Sorted = false; } } } return; }
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