What is the difference between Stack and Queue in C++?



What is the difference between Stack and Queue in C++?..

Answer / Anjali Singh

"Stack: A linear data structure that follows Last-In-First-Out (LIFO) principle. Elements are inserted at one end, called the top, and removed from the opposite end. Stacks have constant-time O(1) average complexity for push(), pop() and peek() operations.nnQueue: A linear data structure that follows First-In-First-Out (FIFO) principle. Elements are inserted at one end, called the rear, and removed from the opposite end, called the front. Queues have O(1) average complexity for enqueue() operation and O(n) for dequeue()."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ Interview Questions

What are the different scope C++ provide ?

1 Answers   Amdocs,


How can you force the compiler to not generate them?

1 Answers   Amazon,


what is friend function in C++?

1 Answers   TCS,


What is an abstract class in C++

1 Answers   SwanSoft Technologies,


Find the Factorial of a number using a program.

1 Answers   Accenture,


Write a program to generate the Fibonocci Series in C++.

1 Answers   Accenture,


What does it mean to declare a member function as static in C++?

1 Answers   Amazon,


Define namespace.

2 Answers  


Difference between function overloading and function overriding.

1 Answers   Alter,


What is a memory leak in C++?

1 Answers   Agilent,


What is a class in C++?

2 Answers   Amazon, TCS, UGC Corporation,


Tell me about virtual function

2 Answers  


Categories