I am writing a C++ program, and if I can get a working algorithm, I could really tackle this problem more clearly...
Here's my problem: A permutation of the number 1, 2, ... , n arrive on-line. For example if n = 5 then first it may be that 2 will arrive then 3, then 5, then 1, and then 4 ( ot any other permutation). In the example the permutation is 2, 3, 5, 1, 4. When the next number arrives, the algorithm has two options: print the current number to the output, or store it in a given queue Q. Reguardless of the input string, at any moment the algorithm can also perform an unlimited number of dequeue and enqueue operations.
2006-10-15
14:40:44
·
2 answers
·
asked by
excalibur1502
1
in
Computers & Internet
➔ Programming & Design