English

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

Question

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
Long Answer
Advertisements

Solution

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
  Is there an error in this question or solution?
Chapter 5: Liner List Manipulation - EXERCISE [Page 105]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 5 Liner List Manipulation
EXERCISE | Q 14. | Page 105
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×