[Python] Comparison of Eight Sorting Algorithms

Sorting is the core operation of data processing. The eight sorting algorithms are: Direct Insertion Sort, Hill Sort, Simple Selection Sort, Heap Sort, Bubble Sort, Quick Sort, Merge Sort, and Radix Sort

The following is a sorting diagram:

image

direct insertion sort

Thought


accomplish


effectiveness



Hill sort

Thought


accomplish


effectiveness

simple selection sort

Thought


accomplish


effectiveness

heap sort

Thought


accomplish


effectiveness


Bubble Sort

Thought


accomplish

#Create sorting algorithm 
def buddle_sort( data ):
	for i in range(0,len(data)):
		for j in range(i,len(data)):
			if(data[i] > data[j]):
				data[i],data[j] = data[j],data[i]
	return data
#编写实例验证
lis = [2,4,1,3]
act_lis = buddle_sort(lis)
print(act_lis)

operation result:

[1, 2, 3, 4]

effectiveness


quicksort

Thought


accomplish


effectiveness


merge sort

Thought


accomplish


effectiveness

radix sort

Thought


accomplish


effectiveness

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324899618&siteId=291194637