摘要:
冒泡排序 思路:从列表第一个元素开始,相邻两个相比较,如果前者比后者大,则交换,使最大的最终交换到列表末尾。 alist = [3, 5, 2, 4, 1, 9] def bubbleSort(alist): for i in range(0, len(alist) - 1): for j in r 阅读全文
摘要:
alist = [1, 2, 3, 4, 5, 6, 7, 8] def binarySearch(alist, target): first = 0 last = len(alist) - 1 while first <= last: middle_index = (first + last) / 阅读全文
摘要:
# coding:utf8 class Node(): def __init__(self, _item): self.item = _item self.left = None self.right = None class SortTree(): def __init__(self): self 阅读全文
摘要:
# coding:utf8 class Node(): def __init__(self, _item): self.item = _item self.left = None self.right = None class Tree(): def __init__(self): self.roo 阅读全文
摘要:
# conding:utf8 class Node(): def __init__(self, _item): self.item = _item self.next = None class Link(): def __init__(self): self._head = None def app 阅读全文