subject

The programmer was trying to implement the following algorithm in python For each position, i, of the elements we are given
1.1 Locate the position of the smallest item in the array at an index greater than or equal to i. Call this position index_of_min_item
1.2 Swap the elements at position i and index_of_min_item
An Example Of The Algorithm
Let's says we were given the following values: 12, 45, 10, 8, 13
Iteration 0
Index 0 1 2 3 4
Value 12 45 10 8 13
i = 0 so we find the minimum value at index >= 0 which is 8 at index 3. Swap what is at index 0 and index 3.
Index 0 1 2 3 4
Value 8 45 10 12 13
Iteration 1
Index 0 1 2 3 4
Value 8 45 10 12 13
i = 1 so we find the minimum value at index >= 1 which is 10 at index 2. Swap what is at index 1 and index 2.
Index 0 1 2 3 4
Value 8 10 45 12 13
Iteration 2
Index 0 1 2 3 4
Value 8 10 45 12 13
i = 2 so we find the minimum value at index >= 2 which is 12 at index 3. Swap what is at index 2 and index 3.
Index 0 1 2 3 4
Value 8 10 12 45 13
Iteration 3
Index 0 1 2 3 4
Value 8 10 12 45 13
i = 3 so we find the minimum value at index >= 3 which is 13 at index 4. Swap what is at index 3 and index 4.
Index 0 1 2 3 4
Value 8 10 12 13 45
Iteration 4
Index 0 1 2 3 4
Value 8 10 12 13 45
i = 43 so we find the minimum value at index >= 4 which is 45 at index 4. Swap what is at index 4 and index 4.
Index 0 1 2 3 4
Value 8 10 12 13 45
Completion
At this point, we are done and the values are sorted

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:00
What engine component is shown in the above figure?
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Me and category do i put them in because this is science
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
Does anybody know how to hack into a google account? i had important information on it and it is gone now and i need getting it back.
Answers: 1
You know the right answer?
The programmer was trying to implement the following algorithm in python For each position, i, of...
Questions
question
Computers and Technology, 30.08.2019 20:10
question
Mathematics, 30.08.2019 20:20
Questions on the website: 13722367