What is the difference between a stack and a queue?

devquora
devquora

Posted On: Feb 22, 2018

 

StackQueue
It follows the principle of LIFO (last in first out).It follows the principle of FIFO (first in first out).
It performs the operation of push and pop.It performs the operation of Enqueue and dequeue.
The implementation is simpler here.The implementation is comparatively complex.
Stack does not consist of variants.Queue contains variants like priority queue etc.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Amazon Support Engineer Interview Questions

    Explain What is STP?

    The STP also stands for Spanning Tree Protocol constructs a loop-free logical topography for Ethernet networks. It is a ..

    Amazon Support Engineer Interview Questions

    Write a function to check if a number is prime?

    A prime number is a whole number greater than 1, which is only divisible by 1 and itself. // function check whether a number // is prime or not bool isPrime(int n) { // Corner case if (n...

    Amazon Support Engineer Interview Questions

    Write a regular expression to validate phone number in  XXX-XXX-XXXX format?

    A regular expression to validate phone number in XXX-XXX-XXXX format is follows: /^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/...