Deques
CS361: Advanced Data Structures and Algorithms
Algorithm Animation
August 1999
Quick instructions:
-
when the animation window appears, select desired operations from the Algorithm
menu.
-
When execution pauses inside of an algorithm, press the continue
button to resume.
Things to Try:
- push_back and push_front
- Observe what happens when the start and stop indices reach either end of the vector.
- Observe what happens when we push into a completely filled vector. Do you see why some elements may have to be moved after the vector is resized?
- Use begin and end to position the two iterators, pos1 and pos2
- Use ++ and -- to move those iterators
- Try inserting at pos1 when pos1 is at the beginning and end of the deque and somewhere in the middle.
- Note that, after any insert/erase, the values of pos1 and pos2 might no longer be valid!
- Try erasing all the elements from pos1 up to pos2, especially in the case when both positions are in the interior of the deque.
Email me at zeil@cs.odu.edu
This animation was prepared using the AlgAE animation framework.
AlgAE applets run under Microsoft
Internet Explorer 4.0 (or later) and Netscape
Communicator 4.05 (or later).