Advertisements
Advertisements
प्रश्न
Consider the following unsorted list:
10 5 55 13 3 49 36
Write the position of elements in the list after:
- 5th iteration of bubble sort
- 7th iteration of insertion sort
- 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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
