Question

Sorting: (40 points) a. We studied several sorting algorithms. Every sorting algorithm has their own special reason where it
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Insertion Sort Algorithm


Following are some of the important characteristics of Insertion Sort:
It is efficient for smaller data sets, but very inefficient for larger lists.
Insertion Sort is adaptive, that means it reduces its total number of steps if a partially sorted array is provided as input, making it efficient.
It is better than Selection Sort and Bubble Sort algorithms.
Its space complexity is less. Like bubble Sort, insertion sort also requires a single additional memory space.
It is a stable sorting technique, as it does not change the relative order of elements which are equal.
Insertion Sort Applications
The insertion sort is used when:
the array is has a small number of elements.
there are only a few elements left to be sorted.
Sorting short lists. If you know your lists are never going to contain more than say 25 elements, then insertion sort is an excellent choice. It is very simple and it’s going to be more efficient than any more complicated sort like quick-sort.
Sorting “almost sorted” lists. If you know that no element is more than say 25 locations from its final location in sorted order (the data could have been produced from another program) or that at most say 25 elements are out of order (the remaining elements are already in sorted order), then insertion sort is again an excellent choice. Again it is simple and essentially unbeatable on these kinds of lists.
Sorting Small Sub-lists in Quick-sort. When the current sub-list is small (say <= 25 elements), it is more efficient to use Insertion-sort on the sub-list than to continue recursing down to a base case of a 1 element list in quick-sort. This idea can also be used in merge-sort.

Selection Sort
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.

1) The subarray which is already sorted.
2) 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.
In computer science, selection sort is an in-place comparison sorting algorithm. It has an O(n2) time complexity, which makes it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity and has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.

Merge Sort:

uses in database scenarios, because stable (multi-key sort) and external (results don’t all fit in memory). Useful in distributed scenarios where additional data arrive during or after sorting. Memory consumption prevents wider use on small devices.

Merge Sort is useful for sorting linked lists in O (n log n) time.

It is used in Inversion Count Problem.

We can use it in External Sorting.

If there is a lot of parallelization occurs, then the parallelizing Mergesort is more straightforward than other sort algorithms.

Quick Sort:

Applications: commercial application use quicksort

- genarally it runs fast
-no additional memory is required
life critical:-
1.medical monitoring
2.life support in aircraft & spacecraft)
-mission critical :-
1.monitring & control in industrial & reaserch plants handling dangerous material
2.control for aircraft.
3.defence
When there is a limitation on memory then randomised quicksort can be used. merge sort is not an in-place sorting algorithm and requires some extra space.

Add a comment
Know the answer?
Add Answer to:
Sorting: (40 points) a. We studied several sorting algorithms. Every sorting algorithm has their own special...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a. We studied several sorting algorithms. Every sorting algorithm has their own special reason where it...

    a. We studied several sorting algorithms. Every sorting algorithm has their own special reason where it can only use. Can you explain carefully in which situation the following algorithms would be best sorting algorithm to use in an application. (10 points) i. Insertion sort ii. Selection sort iii. Merge sort iv. Quick sort b. You are given a string of elements as below, Canopus, Mimosa, Betelgeuse, Deneb, Stars, Pollux, Antares, Sirius, Hader i. Your task is to insert the above...

  • Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case...

    Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case run (a) Heap sort (b) Merge sort (c) Quick sort (d) Insertion sort 18. Which statement below is false: (a) Quick uick sort and merge sort are divide and conquer algorithte (b) Counting sort is a linear time sorting algorithm. (e) Insertion sort and quicksort have similar best case (d) Generic minimum spanning tree algorithm is 19. Counting sort and radix sort are linked...

  • Implement and compare sorting algorithms. The task is to sort a list of integers using 5...

    Implement and compare sorting algorithms. The task is to sort a list of integers using 5 sorting algorithms: selection sort insertion sort merge sort heap sort quicksort Your program should include 5 separate sorting methods, though it is fine for them to call some common methods (like "swap") if needed. Each sorting method should also count the number of comparison operations and assignment operations on the array elements during the sorting process. In the main program, two types of array...

  • For java review please help #2 2. (15 points (-14+1)) Compare the execution complexity of sorting...

    For java review please help #2 2. (15 points (-14+1)) Compare the execution complexity of sorting algorithms. Worst Case Average Case Selection Sort (2.1) Bubble Sort (2.2) Insertion Sort (2.3) Radix Sort Merge Sort Quicksort Heap Sort (2.8) (2.9) (2.10) (2.4) (2.5) (2.6) (2.7) (2.12) (2.13) (2.14) 3. (10 points) Answer the following questions for an array based representation of a complete binary tree (say the array name is binTree). (3.1) root of tree bin Tree LoT

  • I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that...

    I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy...

  • Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points;...

    Java We did in lecture, and explain your answer briefly. Problem 4: Sorting practice 14 points; 2 points for each part individual-only Important: When answering these questions, make sure to apply the versions of these algorithms that were discussed in lecture. The Java code for each algorithm can be found in our Sort class. Given the following array: {14, 7, 27, 13, 24, 20, 10, 33 1. If the array were sorted using selection sort, what would the array look...

  • 3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw...

    3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw the trees that result from the following operations: (a) Inserting 142, 400, 205, 127, 100, 320, 160, 141, and 110 into an initially-empty tree (in that order). (b) Deleting 142 from the tree you drew for part (a). 4. (8 points) Draw the unique binary tree that has a preorder traversal of 4, 1, 6, 3, 7, 5, 9, 2, 8 and an inorder...

  • //Generic interface that describes various searching and sorting //algorithms. Note that the type parameter is unbounded....

    //Generic interface that describes various searching and sorting //algorithms. Note that the type parameter is unbounded. However, //for these algorithms to work correctly, the data objects must //be compared using the method compareTo and equals. //In other words, the classes implementing the list objects //must implement the interface Comparable. The type parameter T //is unbounded because we would like to use these algorithms to //work on an array of objects as well as on objects of the classes //UnorderedArrayList and...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • A test harness program for testing sorting methods is provided with the rest of the textbook...

    A test harness program for testing sorting methods is provided with the rest of the textbook program files. It is the file Sorts.java in the ch11 package. The program includes a swap method that is used by all the sorting methods to swap array elements. Describe an approach to modifying the program so that after calling a sorting method the program prints out the number of swaps needed by the sorting method. Implement your approach. Test your new program by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT