1.

Consider the following unsorted list: 90 78 20 46 54 1 Write the list after:1. 3rd iteration of selection sort2. 4th iteration of bubble sort3. 5th iteration of insertion sort Ans. Working :

Answer»

 

Working:

Bubble SortSelection SortInsertion Sort
[1,90,78,46,54,20][1,78,20,46,54,90][78,90,20,46,54,1
[1,20,90,78,54,46][1,20,78,46,54,90][20,78,90,46,54,1]
[1,20,46,90,78,54][1,20,46,78,54,90][20,46,78,90,54,1]
[1,20,46,54,90,78][1,20,46,54,78,90][20,46,54,78,90,1]
[1,20,46,54,78,90][1,20,46,54,78,90][1,20,46,54,78,90]
[1,20,46,54,78,90][1,20,46,54,78,90]

1. 3rd iteration of selection sort: [1,20,46,78,54,90]

2. 4th iteration of bubble sort: [1, 20, 46, 54, 90, 78]

3. 5th iteration of insertion sort: [1, 20, 46, 54, 78, 90]



Discussion

No Comment Found

Related InterviewSolutions