一、什么是队列?

定义:

数据结构:队列(四)

数据结构:队列(四)

二、队列的实现

数据结构:队列(四)

 

1、单向队列

from collections import deque

q = deque()
q.append(1)
q.append(2)
q.append(3)
print(q.popleft())

输出结果

"D:\Program Files\Python35\python3.exe" E:/test/queue.py
1

Process finished with exit code 0

2、内置队列操作文件(相当于linux的tail功能)

1、代码

from collections import deque

f = open('test','r')
q = deque(f,3)

for line in q:
    print(line)

2、test 

12
456fsddsg
7890
45345
768678
sfs
tutrur
hghfj
wtwet
yutyuytu
qwrwrweret
hhrthret

3、输出结果

"D:\Program Files\Python35\python3.exe" E:/BaiduNetdiskDownload/0921/test/queue.py
yutyuytu

qwrwrweret

hhrthret

Process finished with exit code 0

三、队列的实现原理

数据结构:队列(四)

 

 数据结构:队列(四)

四、环形队列

数据结构:队列(四)

 

数据结构:队列(四)

 

 

数据结构:队列(四)

 

相关文章:

  • 2021-05-08
  • 2021-11-21
  • 2021-04-17
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2021-07-04
  • 2021-08-19
  • 2021-10-12
  • 2021-05-15
相关资源
相似解决方案