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?
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 create a program that does the following: Modify the LinkedList1 class by adding sort()...
Using Java create a program that does the following: Modify the LinkedList1 class by adding sort() and reverse() methods. The reverse method reverses the order of the elements in the list, and the sort method rearranges the elements in the list so they are sorted in alphabetical order. Do not use recursion to implement either of these operations. Extend the graphical interface in the LinkedList1Demo class to support sort and reverse commands, and use it to test the new methods....
In which section of the small intestine does the most chemical digestion take place? Question options:...
In which section of the small intestine does the most chemical digestion take place? Question options: Jejunum Ileum Duodenum Pylorus Cecum Which type of cell lines the stomach? Question options: Simple cuboidal epithelial cells Simple columnar epithelial cells Pseudostratified columnar epithelial cells Stratified columnar epithelial cells Simple squamous epithelial cells Which of the following is not associated with Mechanical Digestion? Question options: The teeth Physical break down of food Enzymes breaking down food Chewing and grinding of food Mastication The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT