A. For the basic ADT Stack operations, list all cases when a StackException will be thrown.
b. For the basic ADT Queue operations, list all cases when a QueueException will be thrown.
Answer a) The cases where a Stack exception will be thrown are:
1) The pop operation or command will throw a StackExcpetion when it tries to pop out an element in an empty stack.
2) The push operation or command will throw a StackExcpetion when it tries to add an element in an array based stack but the stack is already full.
Answer b) The cases where a Queue exception will be thrown are:
1) When a dequeue operation or command is applied on an empty queue it work throw an QueueUnderflowException
2) When an enqueue operation or command is applied on a queue which is full it will throw an QueueUnderFlowException
If you liked the solution then give a thumbs up ? it will be really appreciated ?
Get Answers For Free
Most questions answered within 1 hours.