60 642
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #59460 in Java | JSP | JSF for ariel

Question #59460
Explain why the array implementation of a stack does not require elements to be shifted but the (non-circular) array implementation of a queue does.
Expert's answer
In case with stack adding following elements: 1, 2, 3, 4, 5.
Then deleting two elements from stack will have the following result:
1, 2, 3, NoneType, NoneType. And memory will be cleaned automatically by deleting two last slots.

In case with queue adding following elements: 1, 2, 3, 4, 5.
Then deleting two elements from queue will have the following result:
NoneType, NoneType, 3, 4, 5. Which means that memory can’t be cleaned automatically, and to do so you have to shift elements.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions