Question

A. For the basic ADT Stack operations, list all cases when a StackException will be thrown....

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.

Homework Answers

Answer #1

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 ?

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
- implement the Stack ADT using the linked list approach. Use C++ program language #include "StackLinked.h"...
- implement the Stack ADT using the linked list approach. Use C++ program language #include "StackLinked.h" template StackLinked::StackLinked (int maxNumber) { } template StackLinked::StackLinked(const StackLinked& other) { } template StackLinked& StackLinked::operator=(const StackLinked& other) { } template StackLinked::~StackLinked() {    clear(); } template void StackLinked::push(const DataType& newDataItem) throw (logic_error) {    } template DataType StackLinked::pop() throw (logic_error) { } template void StackLinked::clear() {    StackNode* t;    while ( top != NULL)    {        t = top;       ...
For each of the following situations, which of the following ADTs would be most appropriate, and...
For each of the following situations, which of the following ADTs would be most appropriate, and explain (1) Queue ADT; (2) Stack ADT; (3) Ranked or Positional Sequence ADT; (4) None of these. a. The customers at the deli counter who take numbers to mark their turn. b. An alphabetic list of names. c. Integers that need to be sorted. d. Execution environments of a recursive method. e. The items on a cash register tape. f. A word processor that...
Chapter 18 Lab – Design and code your own LIFO Stack using single liked list to...
Chapter 18 Lab – Design and code your own LIFO Stack using single liked list to hold a list of integers. Use the C++ “struct” structure to create your SLL nodes. Node position numbering should start with one. Your program should include the main program to test and demonstrate one function for each Stack operations including: InitStack – Initialize LIFO Stack PushStack – Add an item to top of Stack at PrintStack – Print out the Stack items PopStack –...
Q: Implement an equals method for the ADT list that returns true when the entries in...
Q: Implement an equals method for the ADT list that returns true when the entries in one list equal the entries in a second list. In particular, add this method to the class AList. The following is the method header: public boolean equals (Object other) public class AList<T>{ private T list[]; private int capacity = 100; private int numOfEnteries =0; public AList(){ list = (T[])new Object[capacity + 1]; } public void add(T element){ numOfEnteries++; if (numOfEnteries >capacity) System.out.println ("Exceed limit");...
Generate test cases for the following code by using Basic Path Testing. void sort(int a[ ],int...
Generate test cases for the following code by using Basic Path Testing. void sort(int a[ ],int N) {     int i,j,p,t;        for(i=0;i<N-1;i++)        {     p=i;               for(j=i+1;j<N;j++)                      if(a[j]>a[p]) p=j;               if(p!=i)               {     t=a[p];  a[p]=a[i];     a[i]=t;   }        } } a)       Draw CFG. b)       How many basic paths for the CFG? c)        List the basic paths. d)       Generate test cases from it.
   vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14...
   vi. Assume that a linked list stores the data, 20, 11, 13, 19, 12, 14 in that order. Assume that Node head references the first item in the list. What is the result to the linked list of       the following instructions? Assume that newNode          is a Node, already constructed. newNode.data = 1;                         newNode.next = head.next;                         head = newNode;       a. The value 1 is inserted into the linked list before 20       b. The...
Discuss and exemplify Basic Human Rights and Responsibility. Include a list of all references used to...
Discuss and exemplify Basic Human Rights and Responsibility. Include a list of all references used to support your answer.
List and describe two possible undesirable outcomes when writing a highly detailed Emergency Operations Plan (EOP).
List and describe two possible undesirable outcomes when writing a highly detailed Emergency Operations Plan (EOP).
(A) List all of the possible (n, l, m1) combinations (i.e. orbitals) when n=3 (B) List...
(A) List all of the possible (n, l, m1) combinations (i.e. orbitals) when n=3 (B) List all the possible (n, l, m1) combinations (i.e. orbitals) for the 5d orbitals
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT