JAVA
Each of the following 6 questions refer to the following list of
values in the order as shown.
555 288 633 666 444 422 399 477
21. Print the values in the order they would have after the first
round of bubble sort’s bubbling
operation low to high.
22. Print the values in the order they would have after the first
round of selection sort for sorting
low to high, assuming it selects the max.
23. Print the values in the order they would have after the first
round of selection sort for sorting
low to high, assuming it selects the min.
24. Print the values in the order they would have after the first
round of a binary radix sort for
sorting low to high.
25. Print the values in the order they would have after the first
round of a decimal radix sort for
sorting low to high.
26. Print the values in the order they would have after the first
round of quicksort’s 3-way
partition operation. Assume it chooses the last element in the
array as the pivot.
27. Theoretically (if it could be done), what would be the best
value to use as the pivot for a
quicksort round of partitioning?
21. After first round of bubbling, the array is as follows:
288 555 633 444 422 399 477 666
22. After first round of selection sort that selects the max element, the max element is moved to the end. The array is as follows:
555 288 633 444 422 399 477 666
23. After first round of selection sort that selects the min element, the min element is moved to start. The array is as follows:
288 555 633 666 444 422 399 477
24. The array is sorted based on the last digit in the binary notation of the elements. Thus even numbers (last binary digit 0) appear after odd numbers(last binary digit 1) after first pass of binary radix sort.
After the first round of binary radix sort, the array is as follows:
288 666 444 422 555 633 399 477
25.In decimal radix sort, in the first pass, array is sorted on the last decimal digit.
422 633 444 555 666 477 288 399
26. In quick sorts, 3 way partition, the last element is selected as pivot. All elements lesser than pivot occur at the beginning , then the elements equal to the pivot appear and finally the elements greater than the pivot appear. The array after first round of sorting is: (477 is the pivot)
288 444 422 399 477 555 633 666
JAVA Each of the following 6 questions refer to the following list of values in the...
555 288 633 666 444 422 399 477 Print the values in the order they would have after the first round of a binary radix sort for sorting low to high. Print the values in the order they would have after the first round of a decimal radix sort for sorting low to high. Print the values in the order they would have after the first round of quicksort’s 3-way partition operation. Assume it chooses the last element in the...
Sorting Sort the following array using the quick sort algorithm: (4 Marks) a. 12 26 8 9 7 0 4 Pivot selection is defined to be the first element of each sub-list. Show the array before and after each quicksort round (when the array is partitioned after placing the pivot at its correct position). Also, clearly highlight the pivot in each partition b. Consider an unsorted array of integers of size n. Write a Java program to arrange the array...
Java
1. (5) Assume selection sort is applied to the following array. Show the state of the array after the first pass of the outer loop. 50 35 15 100 90 20 10 25 2. (5) Assume bubble sort is applied to the following array. Show the state of the array after the first pass of the outer loop 50 35 15 100 90 20 10 25 3. (5) Assume quicksort is applied to the following array. Show the state...
Directions: Problem 1: Write (using pen-and-paper rather than code) the list after each pass of quick and merge sort for the following list of numbers. Assume that you are sorting the numbers into ascending order. For quick sort, assume that the first number from the sublist is chosen as the pivot. 54 17 21 18 4 7 19 41 Problem 2: Write the list after each pass of the quick sort algorithm for the following list of numbers, using the...
[6 marks] Suppose we run three sorting methods on copies of an array containing 1, 7, 19, 24, 7, 49 (in that order). Suppose we stop each method before it is complete (as described below). In each case, give the order of the values as they would appear in the array after we stopped each sort. a. Quick sort (that uses the median-of-three technique to find its pivot) stopped IMMEDIATELY BEFORE the first recursive call starts. b. Radix sort stopped...
JAVA HELP Organize the following sorting algorithms in order of speed of completion for a large list of non-negative 3-digit integers that are almost completely sorted already. (Note that 1 would finish first and 4 would finish last.) Group of answer choices Radix Sort [ Choose ] 2 3 4 1 Bubble Sort [ Choose ] 2 ...
7.11 LAB: Sorting user IDs Given a main() that reads user IDs (until -1), complete the quicksort() and partition() methods to sort the IDs in ascending order using the Quicksort algorithm, and output the sorted IDs one per line. Ex. If the input is: kaylasimms julia myron1994 kaylajones -1 the output is: julia kaylajones kaylasimms myron1994 Code: import java.util.Scanner; import java.util.ArrayList; public class UserIDSorting { // TODO: Write the partitioning algorithm - pick the middle element as the // pivot,...
c++ please read all question edit the program to test different random sizes of the array and give me the time in a file will be like random size of the array and next to it the time it took for each size Im trying to do time analysis for Quick sort but i keep getting time = 0 also i want edit the program to test different random sizes of the array and give me the time in a...
The following C code keeps returning a segmentation fault! Please debug so that it compiles. Also please explain why the seg fault is happening. Thank you #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> // @Name loadMusicFile // @Brief Load the music database // 'size' is the size of the database. char** loadMusicFile(const char* fileName, int size){ FILE *myFile = fopen(fileName,"r"); // Allocate memory for each character-string pointer char** database = malloc(sizeof(char*)*size); unsigned int song=0; for(song =0; song < size;...
Language C++ (Please include a short description & Screenshot of output) Implement a Priority queue using a SORTED list. Use Quick sort after adding a new node. Example of quick sort below. Adopt to your program the code below. #include <iostream> void quickSort(int a[ ], int first, int last); int pivot(int a[], int first, int last); void swap(int& a, int& b); void swapNoTemp(int& a, int& b); void print(int array[], const int& N); using namespace std; int main() { int test[]...