Question

In: Computer Science

Question #1 (Java) - Which sorting does in-place sorting? - Which sort does the minimum swap...

Question #1 (Java)

- Which sorting does in-place sorting?

- Which sort does the minimum swap to order ascending/descending manner?

Note: I just need a short answer to the question no code.

Solutions

Expert Solution

Answer:---

I am using Selection Sort for in-place sorting

The selection sort algorithm sorting an array by repeatedly finding the minimum element. That we considering ascending order from unsorted part and placed at the beginning.

The Selection sort algorithm maintains two subarrays in a given array.

· The subarray which is already sorted.

· Remaining subarray which is unsorted.

In every iteration of selection sort, the minimum element considering ascending order from the unsorted subarray is picked and moved to the sorted subarray.

Worst complexity: n^2

Average complexity: n^2

Best complexity: n^2

Space complexity: 1

Following Steps :--

arr[] = 12 60 64 25 13 10

// Given array 10 is minimum so we are swapping from 12 (first position) to 10

10 60 64 25 13 12

// Next smallest value 12, this value swap from 60(second position) to 12

10 12 64 25 13 60

// Next smallest value 13, this value swap from 64(third position) to 13

10 12 13 25 64 60

// Next smallest value 25, we are placed same position

10 12 13 25 64 60

// Next smallest value 60, this value swap from 64(last position) to 60

10 12 13 25 60 64


Related Solutions

IN JAVA. Which sorting does in place sorting? Which sort does the minimum swap to order...
IN JAVA. Which sorting does in place sorting? Which sort does the minimum swap to order ascending /desendinf manner?
In Java: Write two advanced sorting methods of your choice: (Shell Sort OR Radix Sort) AND...
In Java: Write two advanced sorting methods of your choice: (Shell Sort OR Radix Sort) AND (Merge Sort OR Quick Sort). If you choose Shell Sort, experiment with different incremental sequences to see how they affect the algorithm's run time efficiency (count the number of comparisons and exchanges). If you choose to implement Radix Sort, answer the following question as well: Can you write a version of Radix Sort for String objects? If yes, explain how. If not, explain why....
Which of the following sorting algorithms are stable: insertion sort, selection sort, merge sort and quick...
Which of the following sorting algorithms are stable: insertion sort, selection sort, merge sort and quick sort? Give a simple scheme that makes any sorting algorithm stable. How much additional time and space does your scheme entail?
Comparing (Sort Algorithms) Both of the two sorting algorithms will do "sort" on arrays which would...
Comparing (Sort Algorithms) Both of the two sorting algorithms will do "sort" on arrays which would contain x randomly generated integers where the value of x would be 10000, 20000, 40000 and 80000 (inputs). The parts of the program should be followed as..... 1. Set x = 10000, randomly generate x integers. Call qsort function to sort these integers and get the execution time. 2. Randomly generate another x integers. Call your own sorting algorithm and get the execution time....
Which Sorting algorithm are in place algorithm and which are not? Is it advantageous to design...
Which Sorting algorithm are in place algorithm and which are not? Is it advantageous to design in place sorting algorithm? How this in place term is related to the time complexity and space complexity of the program?
Insertion sort, which is one of the other sorting techniques introduced in this chapter. Create an...
Insertion sort, which is one of the other sorting techniques introduced in this chapter. Create an algorithm to implement an insertion sort. Methods for sorting data files. You should produce a brief report discussing the different sorting options that can be used.
Implement Library Sort in Java which is a version of Insertion Sort with gaps to speed...
Implement Library Sort in Java which is a version of Insertion Sort with gaps to speed up the computation. If the pseudocode in Wikipedia (https://en.wikipedia.org/wiki/Library_sort) is not enough, you can download the research paper from (https://arxiv. org/pdf/cs/0407003.pdf). Below is the algorithm and pseudo code. Implementation Algorithm Let us say we have an array of n elements. We choose the gap we intend to give. Then we would have a final array of size (1 + ε)n. The algorithm works in...
1. Richard Florida describes “The Big Sort.” What forces propel this sorting? What are the implications...
1. Richard Florida describes “The Big Sort.” What forces propel this sorting? What are the implications of the Big Sort? 2. Brueckner describes a choice model of homelessness and policies to address homelessness. In particular, he says that well-meaning policies like minimum dwelling size can backfire. How can this happen? 3. Glaeser and Gyourko say that the mortgage interest deduction does not make good policy. Why, according to them, is this the case?
1.Richard Florida describes “The Big Sort.” What forces propel this sorting? What are the implications of...
1.Richard Florida describes “The Big Sort.” What forces propel this sorting? What are the implications of the Big Sort? 2.Glaeser and Gyourko say that the mortgage interest deduction does not make good policy. Why, according to them, is this the case?
using java Which sorting algorithm is this, justify in detail your answer? image of code in...
using java Which sorting algorithm is this, justify in detail your answer? image of code in this link https://lh3.googleusercontent.com/ie0xsSduZTDJ0PYd3skj43dNApdae1rKAXt1OIdkUE9WAyIrrzLndH2pbsVs_laCJ91H61wxBRopgHPcF8PayLjWHiW-Pn72ti02xxb0aNpx87tFUbT7j8lW0bL4=w655
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT