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
a) Write a series of C++ statements (ADT functions) that uses push()and to create a stack...
a) Write a series of C++ statements (ADT functions) that uses push()and to create a stack S1 capable of holding 10 elements and which actually stores the following, the top of the stack being theleftmost element:〈12,2,3,6,5〉 b) Then write a series of statements usingpop()to take those elements out from the stack and enqueue() them all in a queue Q capable of holding 15 elements. Show that queue.(front to be the leftmost element). c) Finally create a second stack S2 in...
- 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;       ...
In the linked-list version of the Stack class, which operations require linear time for their worst-case...
In the linked-list version of the Stack class, which operations require linear time for their worst-case behavior? is_empty() push() pop() None of these operations require linear time.
In five sentences describe the following: a) how you would implement a stack using an array,...
In five sentences describe the following: a) how you would implement a stack using an array, including the push and pop operation b) how you could implement a queue using a linked list, including what type of linked list would be best, the enqueue and dequeue operations
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...
1). Which of the following statements about the operations of a stack is correct? a). Both...
1). Which of the following statements about the operations of a stack is correct? a). Both pop and push take O(1) time. b). The speed of pop and push depends on the stack size. c). Push is faster than pop. d). Pop is faster than push. 2). For a singly linked list with n nodes to find and remove a node from the list takes how long? a). O( log n ) b). O( n^2 ) c). O( 1 )...
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...