English

Differentiate between a stack and a queue.

Advertisements
Advertisements

Question

Differentiate between a stack and a queue.

Distinguish Between
Advertisements

Solution

  Stack Queue
1. The stack is based on the LIFO (Last In First Out) principle. The queue operates on the FIFO (First In, First Out) principle.
2. Insertion Operation is called Push Operation. The insertion operation is known as the Enqueue Operation.
3. Deletion Operation is termed Pop Operation. The deletion operation is known as the dequeue operation.
4. Push and Pop operation occurs from one end of the stack. Enqueue and dequeue. Operation occurs from a separate end of the line.
5. The most accessible element is termed the Top, while the least accessible element is called the Bottom of the stack. The insertion end is termed the Rear End, while the deletion end is called the Front End.
6. Simple implementation Compared to the stack, the implementation is more complex.
7. Only one pointer is used to perform operations. Two pointers are used to perform operations.
8. Empty condition is checked using
Top=-1
Empty condition is checked using
Front=-1 | |
Front=Rear+1.
9. Full condition is checked using
Top=Max-1.
Full condition is checked using
Rear=Max-1.
10. There are no variants available for stack. There are three sorts of variants, including circular queue, double-ended queue, and priority queue.
11. It can be regarded as a vertical collection of visuals. Can be regarded a horizontal collection graphic.
12. Used to overcome recursive-type difficulties. Used to tackle problems with sequential processing.
shaalaa.com
Basic Data Structures (Stack, Queue, Dequeue)
  Is there an error in this question or solution?
2022-2023 (March) Official

RELATED QUESTIONS

---data structure does not require contiguous memory allocation

(i) Array

(ii) String

(iii) Pointer Array

(iv) Linked List


What is Data Structure? 


Define:

(i) Tree

(ii) Binary Tree

(iii) Extended Binary


What is a linked list?


Explain with a flowchart the following control structure:

Selection Logic


How linked list are represented in Memory?


Define the following term with reference to Tree:

Root


Define the following term with reference to Tree:

Leaf


Define the following terms with reference to Tree : Sibling


What is Array?


Define Array and Pointer Array in the data structure.


Explain Linear data Structure and Non-linear Data Structure.


Define Entity.


What is a binary tree?


What is Record?


 Explain memory representation of linked list with example.


State the principle by which the stack data structure works.


A Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out).

Define a class Queue with the following details:

Class name Queue
Data member/instance variable:
dat[ ] array to hold the integer elements
cap stores the maximum capacity of the queue
front to point the index of the front
rear to point the index of the rear
Member functions/methods:
Queue(int max) constructor to initialize the data member cap = max, front = rear = 0 and create the integer array
void add_dat(int v) to add integers from the rear index if possible else display the message(“Queue full”)
int pop_dat( ) to remove and return elements from front, if any, else returns -999
void display() to display elements of the queue

Specify the class Queue giving the details of void add_dat(int) and int pop_dat( ). Assume that the other functions have been defined.

The main( ) function and algorithm need NOT be written.


Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×