Advertisements
Advertisements
प्रश्न
Consider the following lists:
List 1:
| 2 | 3 | 5 | 7 | 11 |
List 2:
| 11 | 7 | 5 | 3 | 2 |
If the lists are sorted using Insertion sort then which of the lists List1 or List 2 will make the minimum number of comparisons? Justify using diagrammatic representation.
संक्षेप में उत्तर
Advertisements
उत्तर
In case of sorting in Ascending order, List 1 will make minimum number of comparisons as it is already in ascending order.
In case of Descending order, List 2 will make minimum number of comparisons as it is in descending order.
Following diagram shows comparisons for ascending order sorting:


shaalaa.com
Insertion Sort in Python
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
