Q. Carefully read the following description and try to identify the sorting technique it is talking about.


(a) In this, every element is compared with its next adjacent element and if the two elements are not in proper order, the two elements are swapped in place. If there are n elements in total, then n comparisons will place the largest element at the last position. Next time, beginning with first two elements and continuing with next elements, n-1 comparisons will place the 2nd largest element at the 2nd last position.

(b) In this, we divide the list/array in two parts: (a) sorted part (which has no element in the beginning), (b) unsorted part (which has all the elements in the beginning). Every iteration is performed with an aim of putting the first element of unsorted part at the correct position in sorted part. Each such placement adds one element to sorted part and removes one element from unsorted part.


Answer :-


(a) Bubble sort

(b) Insertion sort

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post