QUESTION 1. What are the various applications of a stack data structure?
QUESTION 2. When do you get error message “Queue overflow” and “Queue underflow”? Explain with example.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
ANSWER 1:
the various Applications of Stack in Data Structure:
answer 2:
A queue may have a limited space depending on the implementation. We must implement check conditions to see if we are not adding or deleting elements more than it can maximum support.
The underflow condition checks if there exists any item before popping from the queue. An empty one cannot be dequeued further.
if(front == rear)
// underflow condition
The overflow condition checks if the queue is full (or more memory is available) before enqueueing any element. This prevents any error if more space cannot be allocated for the next item.
if(rear == SIZE-1)
// overflow condition