Suppose you have a deque D containing the numbers (1,2,3,4,5,6,7,8), in this order. Suppose further that you have an initially empty queue Q. Give a code fragment that uses only D and Q (and no other variables) and results in D storing the elements in the order (1,2,3,5,4,6,7,8).

Respuesta :

Answer:

The answer is given in attached document    

Explanation:

The explanation is given in the attached document.

Ver imagen mahamnasir

In this exercise we have to use the computer language knowledge in python to write the code as:

the code is in the attached image.

In a more easy way we have that the code will be:

In the above method queue() we have a dequeue D containing the numbers (1,2,3,4,5,6,7,8) as a list. pop() function is used to remove or pop the items from D in the same order they were pushed.

See more about python at brainly.com/question/25870717

Ver imagen lhmarianateixeira