Explain why the array implementation of a stack does not require elements to be shifted but the noncircular array implementation of a queue does.

What will be an ideal response?


All operations on a stack occur on one end of the stack (the top). Therefore, the bottom of the stack can remain at location 0 of the array at all times. Operations on a queue, on the other hand, occur at both ends – additions to one end and removals from the other. If a non-circular array is used, the end can "move away" from index 0, requiring a shift in the elements to keep the elements rooted at that location.

Computer Science & Information Technology

You might also like to view...

Label control names begin with ____.

A. label B. tag C. lab D. lbl

Computer Science & Information Technology

Print integer 100 in octal, hexadecimal and decimal, using stream manipulators and separated by tabs.

What will be an ideal response?

Computer Science & Information Technology

You can choose a template for a new presentation from the ________

A) Start screen B) Ribbon C) Lock screen D) Slide pane

Computer Science & Information Technology

The subcontainer found under both the Computer and User Configuration Policies and Preferences containers that holds script and security settings is called ______________

a. Administrative templates b. Policies c. Preferences d. Windows Settings

Computer Science & Information Technology