हिंदी

Consider the following unsorted list: 10 5 55 13 3 49 36 Write the position of elements in the list after: a. 5th iteration of bubble sort b. 7th iteration of insertion sort

Advertisements
Advertisements

प्रश्न

Consider the following unsorted list:

10     5     55     13     3     49     36

Write the position of elements in the list after:

  1. 5th iteration of bubble sort 
  2. 7th iteration of insertion sort 
  3. 4th iteration of selection sort
दीर्घउत्तर
Advertisements

उत्तर

Initial list: [10, 5, 55, 13, 3, 49, 36]

Sorting method and iteration Position/status of elements
(a) Bubble sort — 5th iteration [3, 5, 10, 13, 36, 49, 55]
(b) Insertion sort — 7th iteration [3, 5, 10, 13, 36, 49, 55]
(c) Selection sort — 4th iteration [3, 5, 10, 13, 55, 49, 36]

Note: In the usual insertion-sort implementation, a list of seven elements has six insertion passes because the first element is already considered sorted. If the first element is counted as iteration 1, the 7th iteration gives the fully sorted list shown above.

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 5: Liner List Manipulation - EXERCISE [पृष्ठ १०५]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 5 Liner List Manipulation
EXERCISE | Q 14. | पृष्ठ १०५
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×