There are more swappings in this algorithm. In insertion sort we put the element to its right position by shifting all the previous elements whatever be the condition is. We don't swap with each previous element which is smaller or bigger.
@devanshsolani25934 жыл бұрын
I find this explanation to be extremely poor. Im following the entire playlist so I feel it as compared to other videos.
@nikhilpatil24824 жыл бұрын
in code initially sliceend=0 hence pos also 0 and if it is true the while condition is ended because of 1st condition is pos>0 which is completely false even code is correctly run why is this
@pavanashadapu75034 жыл бұрын
this becacuse at 0 it becomes 0 and 0-1 that is 0 and -1 here -1 is last element of array so it compares first term and last that we don't want and aslo insertion sort work from right to left at 0 there is no left value so it staert at 1 and compares 1 and 0 this is how insertion works
@pragalbhvashishtha77114 жыл бұрын
The first element where sliceend is zero requires no comparisons to it's left. The while is nested inside, hence when we go to the next element in for loop, sliceend is updated and hence pos as well
@Impeccable_content5 жыл бұрын
sir ,your code is not working ,
@saikrishnamusunuru62744 жыл бұрын
What if second paper marks= firstone ??
@vishnushashank15242 жыл бұрын
Insertion sort algorithm is stable which means if same numbers are given in input their order is not changed
@thesweetspirit34585 ай бұрын
very bad teaching quality... just watching it cz clg has made us register it for a dsa certificate at a cost of 500rs