157k views
1 vote
Write a PYTHON program to sort a list of numbers(get the list as input) using selection sort and bubble sort.

Selection sort (5 points)

Pseudo Code: (Each line of pseudo-code converts to one line of code)

Loop from the first element of the list to (n-1 )th element(i)

Store the minimum index as i

Loop from the second element to nth element (j)

Compare the min index element and the current loop element(j)

If the current element is less than the min index

Store this index as the min index

#At the end of this inner loop’s first run the min index will be holding the index value of the smallest item in the list

Swap the ith element with the min index element

1 Answer

3 votes

Answer:

c = 1 # global variable

def add():

c = c + 2 # increment c by 2

print(c)

add()

Step-by-step explanation:

User Vikhyat
by
5.0k points