数据结构python(一)

大O记法:f(x)=2x, g(x)=x, f(n)=O(g(n))
时间复杂度:T(n)=O(g(n))

顺序表:
在这里插入图片描述
链表:在这里插入图片描述
双向链表
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190114111707280.png?x-oss-process=ima在这里插入图片描述
栈:在这里插入图片描述

队列
在这里插入图片描述
在这里插入图片描述
冒泡排序:
在这里插入图片描述

def maopao_sort(list):
    n=len(list)
    for j in range(n-1):
        for i in range(0,n-1-j):
            if list[i]>list[i+1]:
                list[i],list[i+1]=list[i+1],list[i]

L = [1, 4, 7, 3, 4, 2, 5, 7, 3, 2]
print(maopao_sort(L))

选择排序:
def chocie_sort(list): n=len(list) for j in range(n-1): for i in range(1+j,n): if list[j]>list[i]: list[j],list[i]=list[i],list[j] return list L = [1, 4, 7, 3, 4, 2, 5, 7, 3, 2] print (chocie_sort(L))

猜你喜欢

转载自blog.csdn.net/q386538588/article/details/86476570
今日推荐