retagged by
4,396 views

4 Answers

2 votes
2 votes

  (B) False, False

A Sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.

Quick Sort and Selection Sort  are not stable because it swaps non-adjacent elements.

Example: Given [2, 2, 1], the '2' values will not retain their initial order.

2 votes
2 votes

The stability of a sorting algorithm is concerned with how the algorithm treats equal (or repeated) elements. Stable sorting algorithms preserve the relative order of equal elements, while unstable sorting algorithms don’t. In other words, stable sorting maintains the position of two equals elements relative to one another.

 

Several common sorting algorithms are stable by nature, such as Merge SortTimsortCounting SortInsertion Sort, and Bubble Sort. Others such as QuicksortHeapsort and Selection Sort are unstable.

0 votes
0 votes
option B )False,False , both selection sort and quick sort are not stable because the relative ordering of elements is not maintained in both the cases.
0 votes
0 votes

(B).False, False

In selection sort algorithm smallest element in unsorted array is shifted to its correct position in an array. The number of times sorting takes place will always be one less than the number of integer elements in an array.

https://www.flowerbrackets.com/selection-sort-java/

Basically quicksort is a divide and conquer algorithm. Quicksort is one of the widely used sorting algorithm. Because it is used to sort large datasets or lists.

https://www.flowerbrackets.com/quicksort-java/

Answer:

Related questions

3 votes
3 votes
2 answers
1
admin asked Mar 31, 2020
3,920 views
Which of the following sorting procedures is the slowest?Quick SortMerge SortShell SortBubble Sort
0 votes
0 votes
1 answer
2
admin asked Mar 31, 2020
1,855 views
What is the type of the algorithm used in solving the $4$ Queens problem?GreedyBranch and BoundDynamicBacktracking
5 votes
5 votes
2 answers
3
admin asked Mar 31, 2020
1,819 views
Complexity of Kruskal's algorithm for finding minimum spanning tree of an undirected graph containing $n$ vertices and $m$ edges if the edges are sorted is:$O(mn)$$O(m)$$...
1 votes
1 votes
4 answers
4