Question: Use Java for the following: Write down a sort method to sort an array of String using bubble-sort algorithm. Bubble sort algorithm makes several passes
Use Java for the following:
Write down a sort method to sort an array of String using bubble-sort algorithm. Bubble sort algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is not in order, its values are swapped; otherwise the value remains unchanged. The technique is called bubble sort or sinking sort because the smaller values gradually "bubble" their way to the top, and the larger values "sink" to the bottom. Write a test program that reads in 10 String values and invokes the bubble sort method. Display the sorted string array Example run: Enter 10 strings: New York City, Austin, Dallas, Seattle, Washington D.C, Houston, Chicago, Las Vegas, Charlotte, Denver Sorted strings: Austin, Charlotte, Chicago, Dallas, Denver, Houston, Las Vegas, New York City, Seattle, Washington D.C
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
