PegasusWang / python_data_structures_and_algorithms

Python 中文数据结构和算法教程

Home Page:http://pegasuswang.github.io/python_data_structures_and_algorithms/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gitbook勘误

roadlmy opened this issue · comments

您好,在数据结构和算法 04队列有一句可能写错了~

2.看起来队列需要从头删除,向尾部增加元素,也就是 list.insert(0, element) 和 list.append(element)
应该不是insert是 pop

感谢您的教程~

但是不影响理解的 时间复杂度都是 o(n)

已经修改。这里确实有误,感谢指出。

list 实现 queue 也有两种方式。

  • 插入 list.insert(0, item),删除list.pop()
  • 插入 list.append(item), 删除 list.pop(0)