pythonË㷨ʵ¼ù7 ¹é²¢ÅÅÐò
def MergeSort(mylist, low, mid, high):
i = low
j = mid + 1
tmp = []
while i <= mid and j <= high:
if mylist[i] <= mylist[j]:
tmp.append(mylist[i])
i = i + 1
else:
tmp.append(mylist[j])
j = j + 1
while i <= mid:
tmp.append(mylist[i])
i = i + 1
while j <= high:
tmp.append(mylist[j])
j = j + 1
for k in range(low, high):
mylist[k] = tmp[k]
mylist0 = [1, 3, 5, 7, 9, 11, 6, 8, 66, 88, 100]
MergeSort(mylist0, 0, 5, len(mylist0) - 1)
print(mylist0)
Ïà¹ØÎĵµ£º
À´Ô´:
×÷Õß:
Áé½£
1.python ×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨...£©¡¢ÈýÒýºÅ£¨...£©»ò£¨'''...'''£©°üΧ£¬ÈýÒýºÅ°üº¬µÄ×Ö·û´®¿ÉÓɶàÐÐ×é³É£¬Ò»°ã¿É±íʾ´ó¶ÎµÄÐðÊöÐÔ×Ö·û´®¡£ÔÚʹÓÃʱ»ù±¾Ã»Óвî±ð£¬
1.python
×Ö·û´®Í¨³£Óе¥ÒýºÅ£¨'...'£©¡¢Ë«ÒýºÅ£¨"..."£©¡¢ÈýÒýºÅ£¨"""... ......
ÎÒÃǾ³£»á²ÉÓÃÉú²úÕß/Ïû·ÑÕß¹ØϵµÄÁ½¸öÏß³ÌÀ´´¦ÀíÒ»¸ö¹²Ïí»º³åÇøµÄÊý¾Ý¡£ÀýÈçÒ»¸öÉú²úÕßÏ߳̽ÓÊÜÓû§Êý¾Ý·ÅÈëÒ»¸ö¹²Ïí»º³åÇøÀµÈ´ýÒ»¸öÏû·ÑÕßÏß
³Ì¶ÔÊý¾ÝÈ¡³ö´¦Àí¡£µ«ÊÇÈç¹û»º³åÇøµÄ̫С¶øÉú²úÕߺÍÏû·ÑÕßÁ½¸öÒì²½Ï̵߳ÄËٶȲ»Í¬Ê±£¬ÈÝÒ׳öÏÖÒ»¸öÏ̵߳ȴýÁíÒ»¸öÇé¿ö¡£ÎªÁ˾¡¿ÉÄܵÄËõ¶Ì¹²Ïí×ÊÔ´²¢ÒÔÏàͬ
Ëٶȹ¤×÷µÄ¸÷Ïß³ ......
#shellÅÅÐò
def ShellPass(mylist, d):
size = len(mylist)
i = d
while i < size:
if mylist[i] < mylist[i - d]:
tmp = mylist[i]
j = i - d
mylist[j + d] = mylist[j]
j = j - d
while j >= 0 and mylist[j] > ......
#Ö±½ÓÑ¡ÔñÅÅÐò
def SelectSort(mylist):
size = len(mylist)
i = 0
for i in range(0, size):
k = i
for j in range(i + 1, size):
if mylist[j] < mylist[k]:
k = j
if k != i:
tmp = mylist[i]
......