Choose The Correct Function From The Following That Implements #623
Choose the correct function from the following that implements merging in in-place merge 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 - In-place Merge Sort - Quiz No.1.
Choose the correct function from the following that implements merging in in-place merge sort.
void in_place_merge(int arr[], int l, int middle, int r) { int start2 = middle + 1; if (arr[middle] <= arr[start2]) { return; } while (l <= middle+1 && start2 <= r) { if (arr[l] <= arr[start2]) { l++; } else { int val = arr[start2]; int index = start2; while (index != l) { arr[index] = arr[index - 1]; index--; } arr[l] = val; l++; middle++; start2++; } } }
void in_place_merge(int arr[], int l, int middle, int r) { int start2 = middle + 1; if (arr[middle] <= arr[start2]) { return; } while (l <= middle && start2 <= r) { if (arr[l] <= arr[start2]) { l++; } else { int val = arr[start2]; int index = start2; while (index != l) { arr[index] = arr[index - 1]; index--; } arr[l] = val; l++; middle++; start2++; } } }
void in_place_merge(int arr[], int l, int middle, int r) { int start2 = middle + 1; if (arr[middle] <= arr[start2]) { return; } while (l <= middle+1 && start2 <= r) { if (arr[l] >= arr[start2]) { l++; } else { int val = arr[start2]; int index = start2; while (index != l) { arr[index] = arr[index - 1]; index--; } arr[l] = val; l++; middle++; start2++; } } }
void in_place_merge(int arr[], int l, int middle, int r) { int start2 = middle + 1; if (arr[middle] >= arr[start2]) { return; } while (l <= middle && start2 <= r) { if (arr[l] <= arr[start2]) { l++; } else { int val = arr[start2]; int index = start2; while (index != r) { arr[index] = arr[index - 1]; Index++; } arr[l] = val; l++; middle++; start2++; } } }
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