m4 - Lecture C4: Stacks and Queues Response to 'Muddiest...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture C4: Stacks and Queues Response to 'Muddiest Part of the Lecture Cards' (19 respondents) 1) What is “implementation specific exception”, you said it happens when trying to push a new element onto a full stack ? It is implementation defined. In our case with Ada, if you try to add a value to an already full array, an exception will be raised (runtime error / constraint error). On the other hand, if you wrote a better version of your program you might have built in error checks to see that out of bound operations on the array never takes place, maybe instead a “friendly message” will be printed to the Monitor telling the user that the stack/array is full. 2) When a queue is implemented as an array, what happens when tail[Q] = head[Q]? What if tail[Q]=2, head[Q]=3, you add one, and then want to add another element without taking any out ? If you use the same definition of the queue presented in class, then head[Q] is always less than tail[Q]. Head[Q] points at the next item that will be removed/served from the queue. Tail[Q] points at the first empty place in the queue is, that is, where next item being enqueued will be placed. If the queue is circular, then when tail[Q] = head[Q], then the queue is either empty or
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/28/2012 for the course AERO 16.01 taught by Professor Markdrela during the Fall '05 term at MIT.

Page1 / 3

m4 - Lecture C4: Stacks and Queues Response to 'Muddiest...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online