Question:
Why is the isEmpty() member method called?
Answer:
The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at least one element.This method is called by the dequeue() method before returning the front element. Source: CoolInterview.com
isEmpty() checks stack is empty or not.It returns true stack is empty otherwise false. Source: CoolInterview.com
Answered by: Rehana | Date: 11/17/2009
| Contact Rehana
pop() is one of the most important operation performed onto the stack. This operation remove the topmost element from the stack. But for that we must have to check stack is empty or not. If stack is empty & we are going to perform pop() operation at that time it underflows therefore while doing pop() operation we have to check stack is empty or not this work is done by calling isEmpty() method Source: CoolInterview.com
Answered by: Jibrail Bagwan | Date: 6/1/2010
| Contact Jibrail Bagwan
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|