Which Of The Following Code Performs The Partition Operation In #660
Which of the following code performs the partition operation in QuickSort?
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 - Quicksort - Quiz No.3.
Which of the following code performs the partition operation in QuickSort?
private static int partition(int[] arr, int low, int high) { int left, right, pivot_item = arr[low]; left = low; right = high; while(left > right) { while(arr[left] <= pivot_item) { left++; } while(arr[right] > pivot_item) { right--; } if(left < right) { swap(arr, left, right); } } arr[low] = arr[right]; arr[right] = pivot_item; return right; }
private static int partition(int[] arr, int low, int high) { int left, right, pivot_item = arr[low]; left = low; right = high; while(left <= right) { while(arr[left] <= pivot_item) { left++; } while(arr[right] > pivot_item) { right--; } if(left < right) { swap(arr, left, right); } } arr[low] = arr[right]; arr[right] = pivot_item; return right; }
private static int partition(int[] arr, int low, int high) { int left, right, pivot_item = arr[low]; left = low; right = high; while(left <= right) { while(arr[left] > pivot_item) { left++; } while(arr[right] <= pivot_item) { right--; } if(left < right) { swap(arr, left, right); } } arr[low] = arr[right]; arr[right] = pivot_item; return right; }
private static int partition(int[] arr, int low, int high) { int left, right, pivot_item = arr[low]; left = low; right = high; while(left > right) { while(arr[left] > pivot_item) { left++; } while(arr[right] <= pivot_item) { right--; } if(left < right) { swap(arr, left, right); } } arr[low] = arr[right]; arr[right] = pivot_item; return right; }
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