STUDY
Would you like to react to this message? Create an account in a few clicks or log in to continue.

向下
avatar
Superficial°
文章數 : 2
積分 : 6
注冊日期 : 2020-05-01

Given the list (11, 13, 25, 20, 18, 34) what is the order of the elements after the second iteration of selection sort? Given the list (29, 20, 25, 20, 18, 34) what is the order of the elements after the third iteration of selection sort? Empty Given the list (11, 13, 25, 20, 18, 34) what is the order of the elements after the second iteration of selection sort? Given the list (29, 20, 25, 20, 18, 34) what is the order of the elements after the third iteration of selection sort?

周二 五月 19, 2020 4:25 pm
Given the list (11, 13, 25, 20, 18, 34) what is the order of the elements after the second iteration of selection sort?
Given the list (29, 20, 25, 20, 18, 34) what is the order of the elements after the third iteration of selection sort?
avatar
Josh W.
Contributor
文章數 : 19
積分 : 29
注冊日期 : 2020-05-01

Given the list (11, 13, 25, 20, 18, 34) what is the order of the elements after the second iteration of selection sort? Given the list (29, 20, 25, 20, 18, 34) what is the order of the elements after the third iteration of selection sort? Empty 回復: Given the list (11, 13, 25, 20, 18, 34) what is the order of the elements after the second iteration of selection sort? Given the list (29, 20, 25, 20, 18, 34) what is the order of the elements after the third iteration of selection sort?

周二 五月 19, 2020 4:48 pm
A)
Answer:
--------
[11, 13, 25, 20, 18, 34]

Explanation:
-------------
Selection sort
Original list is [11, 13, 25, 20, 18, 34]
Iteration: 1
> Replace element 11 with minimum number of remaining list [11, 13, 25, 20, 18, 34]
> Minimum element found is 11. so, swap it with element at index 0 which is 11
> List after iteration 1 is [11, 13, 25, 20, 18, 34]

Iteration: 2
> Replace element 13 with minimum number of remaining list [13, 25, 20, 18, 34]
> Minimum element found is 13. so, swap it with element at index 1 which is 13
> List after iteration 2 is [11, 13, 25, 20, 18, 34]

B)
Answer:
--------
[18, 20, 20, 25, 29, 34]

Explanation:
-------------
Selection sort
Original list is [29, 20, 25, 20, 18, 34]
Iteration: 1
> Replace element 29 with minimum number of remaining list [29, 20, 25, 20, 18, 34]
> Minimum element found is 18. so, swap it with element at index 0 which is 29
> List after iteration 1 is [18, 20, 25, 20, 29, 34]

Iteration: 2
> Replace element 20 with minimum number of remaining list [20, 25, 20, 29, 34]
> Minimum element found is 20. so, swap it with element at index 1 which is 20
> List after iteration 2 is [18, 20, 25, 20, 29, 34]

Iteration: 3
> Replace element 25 with minimum number of remaining list [25, 20, 29, 34]
> Minimum element found is 20. so, swap it with element at index 2 which is 25
> List after iteration 3 is [18, 20, 20, 25, 29, 34]
回頂端
這個論壇的權限:
無法 在這個版面回復文章