摘要: 1 from 数据结构.链表的实现 import Link 2 3 4 # 类似于集合的哈希表 5 class HashTable(object): 6 def __init__(self, size=100): 7 self.size = size 8 self.table = [Link() f 阅读全文
posted @ 2021-12-06 21:08 Avery_rainys 阅读(51) 评论(0) 推荐(0)
摘要: 1 class Link: 2 class Node: 3 def __init__(self, item, next=None): 4 self.item = item 5 self.next = next 6 7 class LinkListIterator: 8 def __init__(se 阅读全文
posted @ 2021-12-06 21:07 Avery_rainys 阅读(35) 评论(0) 推荐(0)
摘要: 1 class Queue(): 2 def __init__(self, size=100): 3 self.rear = 0 4 self.front = 0 5 self.size = size + 1 6 self.li = [0 for _ in range(self.size)] 7 8 阅读全文
posted @ 2021-12-06 20:08 Avery_rainys 阅读(26) 评论(0) 推荐(0)
摘要: 1 class Stack: 2 def __init__(self): 3 self.lis = [] 4 5 def pop(self): 6 if not self.is_empty(): 7 return self.lis.pop() 8 else: 9 raise IndexError(" 阅读全文
posted @ 2021-12-06 20:07 Avery_rainys 阅读(33) 评论(0) 推荐(0)
摘要: 1 from collections import deque 2 3 maze = [ 4 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 5 [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], 6 [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], 7 [ 阅读全文
posted @ 2021-12-06 13:01 Avery_rainys 阅读(59) 评论(0) 推荐(0)
摘要: 1 maze = [ 2 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 3 [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], 4 [1, 0, 0, 1, 0, 0, 0, 1, 0, 1], 5 [1, 0, 0, 0, 0, 1, 1, 0, 0, 1], 6 [ 阅读全文
posted @ 2021-12-06 11:24 Avery_rainys 阅读(45) 评论(0) 推荐(0)
摘要: 1 # 为了返回找到列表的下标,故而携带两个参数 2 def binary_search(num, my_list, left, right): 3 if left == right: 4 return left if my_list[left] == num else f'没找到{num}' 5 阅读全文
posted @ 2021-12-06 10:42 Avery_rainys 阅读(23) 评论(0) 推荐(0)
摘要: 1 import random 2 from cal_time import cal_time 3 4 5 @cal_time 6 def insert_sort(_list): 7 for i in range(len(_list) - 1): 8 j = i 9 next_num = _list 阅读全文
posted @ 2021-12-06 10:34 Avery_rainys 阅读(11) 评论(0) 推荐(0)
摘要: 1 import random 2 3 4 def bubbling_sort(_list): 5 length_1 = len(_list)-1 6 for i in range(length_1): 7 is_exchange = False 8 for j in range(length_1- 阅读全文
posted @ 2021-12-06 10:14 Avery_rainys 阅读(18) 评论(0) 推荐(0)
摘要: 1 import random 2 3 4 def select_sort(_lis): 5 for i in range(len(_lis)-1): 6 min_indx = i 7 for j in range(i+1, len(_lis)): 8 if _lis[min_indx] > _li 阅读全文
posted @ 2021-12-06 10:12 Avery_rainys 阅读(21) 评论(0) 推荐(0)