二叉搜索树
摘要:1 # encoding=utf-8 2 3 4 class BSTree: 5 """ 6 二叉搜索树 7 """ 8 middle_list = [] 9 10 class Node: 11 def __init__(self, ele): 12 self.data = ele 13 self.
阅读全文
单链表
摘要:1 # encoding=utf-8 2 3 4 class SingleLinkList(object): 5 """ 6 单向链表, 各节点类型不限 7 """ 8 class Node(object): 9 """ 10 节点域, 存放ele & next 11 """ 12 def __in
阅读全文
保存相同元素的栈, 初始化需指定长度与元素类型
摘要:1 # encoding=utf-8 2 3 4 class Stack: 5 """ 6 相同元素的栈, 初始化需指定长度与元素类型 7 """ 8 def __init__(self, size=25, _type=int): 9 """ 10 __size: the size of stack
阅读全文
保存相同元素的队列, 初始化需指定长度与元素类型
摘要:1 # encoding=utf-8 2 3 class Queue: 4 """ 5 相同元素的队列, 初始化需指定长度与元素类型 6 """ 7 def __init__(self, size=25, _type=int): 8 """ 9 __size: the size of queue 1
阅读全文
保存相同元素的数组, 扩展了四则运算
摘要:1 # encoding=utf-8 2 from __future__ import division 3 from collections import Iterable 4 5 6 class Array(Iterable): 7 """ 8 元素相同的列表 不用指定length 9 """
阅读全文