Data structure - What is the difference between a stack and a Queue?

What is the difference between a stack and a Queue?

Stack is a collection of objects that works in LIFO (Last in First out) mechanism while Queue is FIFO (First in First out). This means that the object that is inserted first is removed last in a stack while an object that is inserted first is removed first in a queue.

What is the difference between a stack and a Queue?

Stack – Represents the collection of elements in Last In First Out order.
Operations includes testing null stack, finding the top element in the stack, removal of top most element and adding elements on the top of the stack.

Queue - Represents the collection of elements in First In First Out order.
Operations include testing null queue, finding the next element, removal of elements and inserting the elements from the queue.
Insertion of elements is at the end of the queue
Deletion of elements is from the beginning of the queue.
Data structure - Can a stack be described as a pointer? Explain
Stack as a pointer - A stack is represented as a pointer. The reason is that, it has a head pointer which points to the top of the stack........
Data structure - What is the recursion?
Recursion - Recursion is an approach in which a function calls itself with an argument......
Data structure - Is it possible to insert different type of elements in a stack? How?
Insert different type of elements in a stack - Different elements can be inserted into a stack. This is possible by implementing union / structure data type.......
Post your comment
Discussion Board
Computer sc
I want to good in computer sc
Edema Emmy 10-10-2016
Difference between stack and queue
Stack is a structure of data that is based on LIFO ( last in first out )
on the other hand queue is a structure that is based on FIFO( FIRST IN FIRST OUT)

IN the stack the new item is inserted with push method and deleted with pop method

on the other hand in the queue the new item is inserted with enqueue method and deleted with dequeue method.
Sandeep khandelwal 04-3-2014