- 博客(5)
- 收藏
- 关注
原创 Python数据结构—列表定义
# Node类 class Node(): def __init__(self, initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newdata): self.d.
2021-07-12 09:30:18
259
转载 Python数据结构—栈,队列,双端队列
# 堆栈 class Stack(): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self):.
2021-07-12 09:28:52
111
原创 Python数据结构—对于无序表和有序表的搜索
# 无序列表的顺序搜索 def sequentialSearch(alist, item): pos = 0 found = False while pos < len(alist) and not found: if alist[pos] == item: found = True else: pos = pos + 1 return found # 有序列表的顺序搜索 def ord.
2021-07-12 09:27:29
267
原创 Python数据结构—排序
# 冒泡排序 def bubbleSort(alist): for passnum in range(len(alist) - 1, 0, -1): for i in range(passnum): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i + 1] alist[i + 1].
2021-07-12 09:20:45
124
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅
1