数据结构
爱乐城的鸟儿
深度学习爱好者,小白级别。
展开
-
排序算法-python
import numpy as np class Sort_all(object): def __init__(self):... def Merge_sort(self,nums): ''' 归并排序的时间复杂度最坏的情况和最优的情况都是Onlogn,因为不管是否顺序,都是需要先分后并 空间复杂度是O(n),因为需要一个result数组来存储 ''' n = len(nums) mid =n.原创 2020-07-09 17:53:23 · 237 阅读 · 0 评论 -
Python-链接表的深刻认识与总结
1.逆序构造链表 图片讲解: 、 逆序构造的时候就像头插法一样,将当前的node作为下一个的node.next. #定义节点 class Node(object): def __init__(self,item,Next=None): self.item=item self.next=Next head=None for i in range (5):...原创 2019-08-14 04:01:47 · 308 阅读 · 1 评论 -
06 0-1背包问题
一、递归求解 1.1 物品不放回 class Solution(object): def snap(self,var_w1,w2,price_): price=0 n=len(var_w1) if w2<=0: return 0 for i in range (n): if...原创 2019-08-28 03:35:18 · 233 阅读 · 0 评论