हिंदी

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? - Computer Science (Python)

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.

संक्षेप में उत्तर

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 5: Sorting - Exercise [पृष्ठ ७९]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 12
अध्याय 5 Sorting
Exercise | Q 3. | पृष्ठ ७९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×