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, 21.06.2019 19:30
Why is it a good idea to leave an interview being courteous and polite?
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
The average cost of one year at a private college in 2012-2013 is $43,289. the average grant aid received by a student at a private college in 2012-2013 is $15,680.   what is the average student contribution for one year at a private college in 2012-2013?
Answers: 3
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
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
Mathematics, 01.09.2021 04:00
question
Mathematics, 01.09.2021 04:00
question
Mathematics, 01.09.2021 04:00
question
Mathematics, 01.09.2021 04:00
question
Mathematics, 01.09.2021 04:00
Questions on the website: 13722367