00:01
Hello student, the algorithm is given to us.
00:03
So the first part of this problem is i have to apply the algorithm on the list of the elements 60, 35, 81, 98 and 14 and 47.
00:14
So these are the elements which are given to us and we have to apply this algorithm.
00:20
So this algorithm will sort the elements.
00:24
So here elements i have written input array is this one and output i have also written because it is sorting so it is doing the sorting and here it is in increasing order.
00:39
So here's how the algorithm work.
00:41
So first algorithm initialize an array count to keep the track the number of the smaller element for the each array in a.
00:48
So here count is initialized and it is keeping the keep track the number of the count of the smaller element.
00:57
So for each element in a compare it to the every other element in a and increment the count in count for each element that is smaller.
01:06
So if element which is smaller that count will be incremented either it will be i or it will be j.
01:14
So here in the else case also it will count of i will increase if i is smaller.
01:23
So in every case smaller number count will be incremented.
01:26
So after counting for each element in a place it in its appropriate position in the sorted array as based on the counts in count.
01:36
So here the sorted array on the basis of the count become 14, 35, 47, 60, 81, 90 which is sorted array.
01:44
So this is sorted array.
01:46
Now come to the second part of this problem.
01:49
Here in this question it is asked is this algorithm stable.
01:54
So i will go with yes this algorithm is stable.
01:58
How we check the stability? stability in the sorting algorithm means when the two elements have the equal key then their relative order is preserved.
02:07
So if suppose in this example if i get this type 14 and 14 was present somewhere else.
02:16
So 14 after 14 the 14 will come means its order is first its position is second.
02:21
So the relative order is preserved in the sorted array...