Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 733 Bytes

Ex_1_3_13.md

File metadata and controls

44 lines (27 loc) · 733 Bytes
title date draft tags categories
Algorithm4 Java Solution 1.3.13
2019-07-04 05:47:10 +0800
false
JAVA
TECH
archives

1.3.13

Problem:

Suppose that a client performs an intermixed sequence of (queue) enqueue and dequeue operations. The enqueue operations put the integers 0 through 9 in order onto the queue; the dequeue operations print out the return value. Which of the following sequence(s) could not occur?

a. 0 1 2 3 4 5 6 7 8 9
b. 4 6 8 7 5 3 2 9 0 1
c. 2 5 6 7 4 8 9 3 1 0
d. 4 3 2 1 0 5 6 7 8 9

Solution:

queue: FIFO.

because the input have an order which is from 0 to 9. 0 must be the first number in any sequence.

a right

b wrong

c wrong

d wrong

Reference: