InterviewSolution
| 1. |
What is the difference between Stack and Queue? |
|
Answer» Stack is a data structure which follows the principle of LIFO (Last In Fast Out) OR FILO (First In Last Out), i.e element inserted at last will be the first to be removed from the stack. Queue is a data structure which follows the principle of FIFO (First In First Out), i.e. element inserted at first to the list will be the first to be removed from the list. For Stack, insertion and deletion of an element are TERMED as PUSH and POP while for Queue, insertion, and deletion of an element are termed as ENQUEUE and DEQUEUE. In JAVA, Stack is a class present in java.util package and Queue is an interface present in java.util package. |
|