Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:00, magicalunicorns47
Arecipients list has been loaded into a document. which commands should be clicked in order to filter the list so that letters will not be printed for recipients who live in a certain state? mailings tab, start mail merge, select recipients, type new list, then insert only contacts from the desired states mailings tab, rules, select recipients, use existing list, then choose a recipients list that includes only contacts in certain states mailings tab, select recipients, use existing list, rules, fill in, then type in certain states mailings tab, rules, skip record select “state” under field name, then type in the state name under “equal to”
Answers: 2
image
Computers and Technology, 23.06.2019 03:00, jarteria0
State 7 common key's for every keyboard
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, cristalcastro901
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
image
Computers and Technology, 25.06.2019 01:00, jimmymurray29
When a new name is registered on the internet, the process can take two hours to four hours four hours to three days two hours to two days one hour to eight hours
Answers: 1
Do you know the correct answer?
The programmer was trying to implement the following algorithm in python For each position, i, of...

Questions in other subjects:

Konu
History, 16.10.2020 15:01