Exercise 4.3. Counting exchanges and comparisons with Selection Sort
Original data set: 60,30,15,51,97,44,37,33
Show how many exchanges and comparisons using the above data set for a selection sort and their totals.
Pass |
Exchanges |
Comparisons |
1 |
||
2 |
||
3 |
||
4 |
||
5 |
||
6 |
||
7 |
||
Totals |
IF YOU UNDERSTOOD IT CLEARLY, PLEASE LIKE/UPVOTE
OTHERWISE, FEEL FREE TO ASK IN COMMENT SECTION
I WILL SURELY HELP YOU!! THANK YOU!!
Exercise 4.3. Counting exchanges and comparisons with Selection Sort Original data set: 60,30,15,51,97,44,37,33 Show how many...
1. The bubble sort: a. Finds the smallest value and exchanges it with the first value, then continues with the second value, third value, etc. b. Is a system of comparisons and exchanges of adjacent elements to move the largest to the bottom of the selected group of values. c. Is a system of comparisons and exchanges of elements that are non-adjacent. The gap is halved at each pass. d. None of the above. For the following array answer Q2...
Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and Insertion Sort. The numbers to be sorted will be obtained using a library function which generates pseudo-random numbers. TO Do 1. Fill an array with 140 real numbers between 0.00 and 945.00. Generate the numbers using the subroutine that generates random numbers. Make a spare copy of the array; you will need it later. 2. Call a subroutine to print the contents of the...
Show the execution of the selection sort algorithm on the following array. Hint: The yellow or shaded squares should be the remaining unsorted values. Pass # 0 1 2 3 4 5 6 7 0 16 11 21 32 41 20 3 9 1 2 3 4 5 6 7 Show the execution of the insertion sort algorithm on the following array. Hint: The yellow or shaded squares should be the remaining unsorted values. Pass # 0 1 2 3...
What is the maximum number of comparisons made when searching a 60 element array with Binary Search? 60 30 5 6 Question 3 (3 points) What is the average number of comparisons made when searching a 60 element array with Linear Search? 06 5 A selection sort algorithm is used to sort an array containing the following values into ascending order. Give the order of the elements after each pass of the sorting algorithm. 6 4 7 2 3 5...
1. (5 marks) Perform a selection sort on the list 23, 59, 34, 13, 31, 10. Show the list after each exchange that has an effect on the list ordering. 2. (5 marks) Explain why the bubble sort algorithm does Ө(n2) comparisons on an n-element list. The bubble-sort algorithm is shown just after question 10 on p. 141. 3. (5 marks) Write the resulting data list, give the ending value of legit, and find the exact number of copies done by the converging...
Write a program in Java that performs the Counting Sort algorithm. a) Create the countingSort method. Use the pseudocode shown in the lecture. b) Test your codes by writing a program that uses the following input array: int[] array_A = {6, 0, 2, 0, 1, 3, 4, 6, 1, 3, 2}; c) Your output should display the following versions of the arrays: I. The original input array A II. The counting array C after the counting (lines 4-5 in pseudocode)...
8 Sorting Algorithms: Bubble, selection, insertion, quick, merge, bucket, radix, counting. 1. A..Which of the above sorting algorithms does TimSort use? 2. Which of the above algorithms sort a REVERSE ORDER list in O(n2 ) (worst case)? 3. Which of the above algorithms sort a REVERSE ORDER list in O(nlogn) (worst case)? 4. Which of the above algorithms sort an ordered list , a reverse ordered list, and a random list (all three) in 0(nlogn) (worst case)? 5. Which of...
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...
16. (5 points) Trace counting sort algorithm as it sorts the array into a descending order. ASSUMPTION: (1) Each data element (i.e., aſil) is associated with a complicated object. As discussed, counting sort with a simple frequency count does not work. (2) Show how to guaranted the stability of repeating values. As we did in the class, please use a subscript to specify the order of the same keved values. (3) Show the steps as detail as possible. A =...
[5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9, 4, 3). Assuming we call the following function using statement selection sort (int array, 7); Please fill the table to show the changes of the array int_array after each iteration. The first column is filled. void selection_sort (int list[], int list_size) for (int i = 0; i < list size - 1; 1++) int current min = list[1]; int current_min_index-i for (int j -...