Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 16, Problem 9MC
Program Description Answer
“Selection sort” is the sorting
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
This algorithm makes several passes through an array and causes the larger values togradually move toward the end of the array with each pass.a. bubble sortb. selection sortc. insertion sortd. sequential sort
Question 8
Sort the following numbers using an "in place" version of a selection sort. This
means that you should have only one array throughout and all elements should be
present at all times. Show each "pass" of the algorithm.
34, 25, 11, 44, 21, 8, 4, 28, 16, 31
Write a program that reads the numbers and sorts them by using the Counting
Sort algorithm and finally search a number from that array using Linear
Search Algorithm.
Input: 3 6 5 4 789
Search Item: 7
Output: Sorted Array: 3 4 5 6 789
Search item 7 is found.
Chapter 16 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 16.1 - Prob. 16.1CPCh. 16.1 - Prob. 16.2CPCh. 16.1 - Prob. 16.3CPCh. 16.1 - Prob. 16.4CPCh. 16.2 - Prob. 16.5CPCh. 16.2 - Prob. 16.6CPCh. 16.2 - Prob. 16.7CPCh. 16.2 - If a sequential search is performed on an array,...Ch. 16.3 - Prob. 16.9CPCh. 16.3 - Prob. 16.10CP
Ch. 16.3 - Prob. 16.11CPCh. 16.3 - Prob. 16.12CPCh. 16.3 - Prob. 16.13CPCh. 16.3 - Prob. 16.14CPCh. 16.3 - Let a[ ] and b[ ] be two integer arrays of size n....Ch. 16.3 - Prob. 16.16CPCh. 16.3 - Prob. 16.17CPCh. 16.3 - Prob. 16.18CPCh. 16 - Prob. 1MCCh. 16 - Prob. 2MCCh. 16 - Prob. 3MCCh. 16 - Prob. 4MCCh. 16 - Prob. 5MCCh. 16 - Prob. 6MCCh. 16 - Prob. 7MCCh. 16 - Prob. 8MCCh. 16 - Prob. 9MCCh. 16 - Prob. 10MCCh. 16 - True or False: If data is sorted in ascending...Ch. 16 - True or False: If data is sorted in descending...Ch. 16 - Prob. 13TFCh. 16 - Prob. 14TFCh. 16 - Assume this code is using the IntBinarySearcher...Ch. 16 - Prob. 1AWCh. 16 - Prob. 1SACh. 16 - Prob. 2SACh. 16 - Prob. 3SACh. 16 - Prob. 4SACh. 16 - Prob. 5SACh. 16 - Prob. 6SACh. 16 - Prob. 7SACh. 16 - Prob. 8SACh. 16 - Prob. 1PCCh. 16 - Sorting Objects with the Quicksort Algorithm The...Ch. 16 - Prob. 3PCCh. 16 - Charge Account Validation Create a class with a...Ch. 16 - Charge Account Validation Modification Modify the...Ch. 16 - Search Benchmarks Write an application that has an...Ch. 16 - Prob. 8PCCh. 16 - Efficient Computation of Fibonacci Numbers Modify...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Nonearrow_forwardLab 16 Implementing bubble sort In this lab, you will implement the bubble sort algorithm. The bubble sort is so called because it compares adjacent items, "bubbling" the smaller one up toward the beginning of the array. By comparing all pairs of adjacent items starting at the end of the array, the smallest item is guaranteed to reach the beginning of the array at the end of the first pass.The second pass begins again at the end of the array, ultimately placing the second smallest item in the second position. During the second pass, there is no need to compare the first and second items, because the smallest element is guaranteed to be in the first position.Bubble sort takes at most n - 1 passes for an array of n items. During the first pass, n - 1 pairs need to be compared. During the second pass, n - 2 pairs need to be compared. During the ith pass, n - i pairs need to be compared. During the last pass, n - (n - 1) or one pair needs to be compared. If, during any pass, no two…arrow_forwardLab 16 Implementing bubble sort In this lab, you will implement the bubble sort algorithm. The bubble sort is so called because it compares adjacent items, "bubbling" the smaller one up toward the beginning of the array. By comparing all pairs of adjacent items starting at the end of the array, the smallest item is guaranteed to reach the beginning of the array at the end of the first pass. The second pass begins again at the end of the array, ultimately placing the second smallest item in the second position. During the second pass, there is no need to compare the first and second items, because the smallest element is guaranteed to be in the first position. Bubble sort takes at most n - 1 passes for an array of n items. During the first pass, n - 1 pairs need to be compared. During the second pass, n - 2 pairs need to be compared. During the ith pass, n - i pairs need to be compared. During the last pass, n - (n - 1) or one pair needs to be compared. If, during any pass, no two…arrow_forward
- Java language onlyarrow_forwardSort the array (D, G, J, F, A, C) using selection sort (show the array after each step).arrow_forwardThe program has four steps: Read the size of an integer array, followed by the elements of the array (no duplicates). Output the array. Perform an insertion sort on the array. Output the number of comparisons and swaps performed. main() performs steps 1 and 2. Implement step 3 based on the insertion sort algorithm in the book. Modify insertionSort() to: Count the number of comparisons performed. Count the number of swaps performed. Output the array during each iteration of the outside loop. Complete main() to perform step 4, according to the format shown in the example below. Hints: In order to count comparisons and swaps, modify the while loop in insertionSort(). Use static variables for comparisons and swaps. The program provides three helper methods: // Read and return an array of integers. // The first integer read is number of integers that follow. int[] readNums() // Print the numbers in the array, separated by spaces // (No space or newline before the first number or after…arrow_forward
- using selection sort algorithm, the intermediate sorting results of sorting the array (1,3,24,19,5,2} in Descending order are: starting: {12,4,25,20,6,3,100} Result of the first iteration: Result of the second iteration: Result of the third iteration: Result of the fourth iteration: { Result of the fifth iteration:arrow_forwardThe first element in each array is accessed with index number 0. (e.g., array[0]). Select one: True Falsearrow_forwardWhich of the following sorting methods execute the least statements when arranging an array and why? 1. Bubble sort 2. Selection sort 3. Insertion sortarrow_forward
- Which algorithm does the following method belong to? step 1: startstep 2: declare array and left, right, mid variablestep 3: perform combine function. if left > right return mid= (left+right)/2 sort(array, left, mid) sort(array, mid+1, right) combine(array, left, mid, right)step 4: Stop Group of answer choices Merge Sort Insertion Sort Selection Sort Quick Sortarrow_forward____ is a type of sorting algorithm that sorts an array by “floating” elements that are larger to the right, and elements that are “smaller” to the left (for ascending order) on each round of the sort.arrow_forwardShow how the Selection Sort works on this list array to sort it in ascending order. 55 35 20 80 90 40 60 95 10 75arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage