Home > Software engineering >  Can you help ah this is a problem of the algorithm
Can you help ah this is a problem of the algorithm

Time:11-10

Problem description:

A set of chaotic sequence of elements in accordance with the rules for the orderly sequence, each time you select the smallest element in unsorted sequences,

Requirements:

1. According to the prompt to complete the program

2. Output selection sort time

Program templates as follows, please complete part TODO,

# # # # # # # # # # # # # # # # # # # # # # # #

# to find the smallest element in the current

Def findSmallest (list) :

//TODO: the current sequence is stored in the smallest of the smallest element

//TODO: initialize the smallest element index location

For I in range (1, len (list)) :

If the list [I]
//TODO: update the smallest element of the current sequence, update the index value



Return smallest_index


#
sorting sequence
Def selectionSort (list) :

Newlist=[]

For I in range (len (list)) :

# Finds the smallest element in the array and adds it to the new array

//TODO: find the smallest element in the current list, and add it to newlist

Return newlist


# test statements

Print (selectionSort ([5, 3, 6, 2, 10]))

CodePudding user response:

This is Python not VB, you send the wrong place?
  • Related