队列:原理、类型与应用
1. 队列操作示例
在进行队列操作时,我们会面临多种选择,如插入元素、删除元素、显示队列内容或退出操作。以下是一个操作示例:
3. display Queue
4. exit
enter the choice of operation you want to do 1
enter the value you want to insert in Queue 2
enter the choice of operation you want to do 1
enter the value you want to insert in Queue 3
enter the choice of operation you want to do 1
enter the value you want to insert in Queue 4
enter the choice of operation you want to do 3
2-> 3-> 4-> NULL
enter the choice of operation you want to do 2
2->
enter the choice of operation you want to do 3
3-> 4-> NULL
这个示例展示了队列插入、删除和显示操作的基本流程。
2. 队列类型
队列主要有以下三种类型:
1. 循环队列(Circular Queue)
2. 双端队