Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 23.3, Problem 23.3.2CP
Program Plan Intro
Sorting:
Sorting is a process where the elements of a list are arranged in a particular order. The order of the list can be either present in the ascending order or descending order.
Bubble sort:
- Bubble sort is a simple sorting
algorithm . - It follows the strategy of comparing the adjacent pairs in the list. If the elements in the pair are unordered, then swap the values; otherwise, no swap is required.
- While sorting, it continuously allocates the largest element to the highest index position of the array.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Apply Selection Sort on the following list of elements: 16, 23, 19, 6, 20, 10, 34, 54
Consider the array {5, 8, 2, 6, 7}. How many exchanges are required to sort the given array using Bubble sort?
a. 3
b. 8
c. 5
d. 7
Sort 3, 5, 7, 8, 1, 9, 2, 4, 6 using the quick sort.
Chapter 23 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 23.2 - Prob. 23.2.1CPCh. 23.2 - Prob. 23.2.2CPCh. 23.2 - Prob. 23.2.3CPCh. 23.3 - Prob. 23.3.1CPCh. 23.3 - Prob. 23.3.2CPCh. 23.3 - Prob. 23.3.3CPCh. 23.4 - Prob. 23.4.1CPCh. 23.4 - Prob. 23.4.2CPCh. 23.4 - What is wrong if lines 615 in Listing 23.6,...Ch. 23.5 - Prob. 23.5.1CP
Ch. 23.5 - Prob. 23.5.2CPCh. 23.5 - Prob. 23.5.3CPCh. 23.5 - Prob. 23.5.4CPCh. 23.6 - Prob. 23.6.1CPCh. 23.6 - Prob. 23.6.2CPCh. 23.6 - Prob. 23.6.3CPCh. 23.6 - Prob. 23.6.4CPCh. 23.6 - Prob. 23.6.5CPCh. 23.6 - Prob. 23.6.6CPCh. 23.6 - Prob. 23.6.7CPCh. 23.6 - Prob. 23.6.8CPCh. 23.6 - Prob. 23.6.9CPCh. 23.7 - Prob. 23.7.1CPCh. 23.7 - Prob. 23.7.2CPCh. 23.8 - Prob. 23.8.1CPCh. 23 - Prob. 23.1PECh. 23 - Prob. 23.2PECh. 23 - Prob. 23.3PECh. 23 - (Improve quick sort) The quick-sort algorithm...Ch. 23 - (Check order) Write the following overloaded...Ch. 23 - Prob. 23.7PECh. 23 - Prob. 23.8PECh. 23 - Prob. 23.10PECh. 23 - Prob. 23.11PECh. 23 - Prob. 23.12PECh. 23 - Prob. 23.13PECh. 23 - (Selection-sort animation) Write a program that...Ch. 23 - (Bubble-sort animation) Write a program that...Ch. 23 - (Radix-sort animation) Write a program that...Ch. 23 - (Merge animation) Write a program that animates...Ch. 23 - (Quicksort partition animation) Write a program...Ch. 23 - (Modify merge sort) Rewrite the mergeSort method...
Knowledge Booster
Similar questions
- (c++)Apply bubble sort on the following data 11,44,55,-6,66,88,22,55,66,10arrow_forwardWrite a program using bubble sort and test it with the following data. Youneed to give the program and show the result.14, 22, 41, 56, 34, 12, 19, 52 c++arrow_forwardExplain Quick sort algorithms with the following set of integers {50 , 70, 60, 90, 40, 80, 10, 20 , 30}arrow_forward
- Write a program to compute the exact value of the number of array accesses usedby top-down mergesort and by bottom-up mergesort. Use your program to plot the values for N from 1 to 512, and to compare the exact values with the upper bound 6N lg Narrow_forwardUse Figure 7.11 as an example to show how to apply the selection-sort approach to sort {3.4, 5, 3, 3.5, 2.2, 1.9, 2}.arrow_forwardFollowing is the partition function for quicksort, where we have used the leftmost number as a pivot. Assume that our array, ARR = {14, 8, 7, 38, 22, 15, 9}, which is 7 in size. What will be the array ARR after we apply "partition(A, 0, 6)"* 9, 15, 22, 38, 7, 8, 14 7, 8, 9, 14, 15, 22, 38 9, 8, 14, 7, 22, 15, 38 9, 8, 7, 14, 22, 15, 38 7, 9, 15, 22, 38, 14, 6 38, 22, 15, 14, 9, 8, 7arrow_forward
- Java! please explain clearly with the answer by hand-writing or typing Using merge sort to sort an array of size n, then use binary search to find (1/2)n elements. Using merge sort to sort an array of size n, then run sequential search on it.arrow_forwardThe best case behaviour occurs for quick sort when the partition function splits the sequence of size n into subarrays of size: Select one: a.n/4 : 3n/4 b.n/4 : 3n/2 c.3n/8 : (5n/8) d.n/2 : (n/2)-1 e.n/2 : n/3arrow_forwardConsider the array that is given below. Provide step by step process to show how the merge sort would sort the array. 13 11 34 20 17 9 32arrow_forward
- Show the steps for sorting 2, 6, 4, 1, 2, 4, 1, 4 using counting sort (first version) with additional arrays B and C. A 2 6 4 1 2 4 1 4 1 2 3 4 5 6 7 8arrow_forwardGiven an array arg[] below, use the incremental approach to sort it in assending order 11 42 35 38 22 45 18 39 3arrow_forward(b) Explain in your own words why even the more efficient versions of bubble sort are considered to be slow algorithms. Illustrate your answer using the example data: {17, 15, 11, 13}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education