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, 22.06.2019 14:30
If the polar bear were taken out of the food chain what would happen to the seal population the seal population would diminish the seal population would grow dramatically the seal population would stay the same the seal population would decrease slightly
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 2
question
Computers and Technology, 23.06.2019 03:30
Ihave a singular monitor that is a tv for my computer. recently, i took apart my computer and put it back together. when i put in the hdmi cord and booted the computer to see if it worked, the computer turned on fine but the screen was blue with "hdmi no signal." i've tried everything that doesn't require buying spare parts, any answer is appreciated!
Answers: 1
question
Computers and Technology, 23.06.2019 20:50
3.11.3 quiz: comparing and analyzing function typesquestion 4 of 102 pointswhat can you say about the y-values of the two functions f(x) = 3x2-3 andg(x)=2* - 3?
Answers: 2
You know the right answer?
The programmer was trying to implement the following algorithm in python For each position, i, of...
Questions
question
Mathematics, 23.04.2020 15:14
question
Mathematics, 23.04.2020 15:16
question
Physics, 23.04.2020 15:21
question
Mathematics, 23.04.2020 15:21
Questions on the website: 13722362