假设Q10.6]是一个循环队列,初始状态为front =rear-0,画出做完下列操作后队列的头尾指 针的状态变化情况,若不能入队,请指出其元素,并说明理由。 d.e入队;d出队;ijk,m入队;1.0.p入队
时间: 2024-05-09 07:14:42 浏览: 84
操作前,队列状态为:
```
front = rear = 0
```
a. 元素d入队后,队列状态变为:
```
front = 0, rear = 1
+---+---+---+---+---+---+---+---+---+---+
| d | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
```
b. 执行出队操作d,队列状态变为:
```
front = 1, rear = 1
+---+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
```
c. 元素ijk,m入队后,队列状态变为:
```
front = 1, rear = 3
+---+---+---+---+---+---+---+---+---+---+
| | i | j | k | m | | | | | |
+---+---+---+---+---+---+---+---+---+---+
```
d. 元素1,0,p入队后,队列状态变为:
```
front = 1, rear = 6
+---+---+---+---+---+---+---+---+---+---+
| | i | j | k | m | 1 | 0 | p | | |
+---+---+---+---+---+---+---+---+---+---+
```
注意:队列长度为10,已经存满,再次入队元素时会发生队列溢出。
阅读全文