Data Structures using C PlusPlus: Chapter 4: Stacks and Queues

Introduction to Queues

Data Structures using C++ Program

Question: What is Queue? Explain by comparing with stack.

Introduction to Queues

Definition : The queue can be formally defined as ordered collection of elements that has two ends named as front and rear. From the front end one can delete the elements and from the rear end one can insert the elements.

For example:

• The typical example can be a queue of people who are waiting for a city bus at the bus stop. Any new person is joining at one end of the queue, you can call it as the rear end. When the bus arrives the person at the other end first enters in the bus. You can call it as the front end of the queue.

• Following Fig. 4.6.1 represents the queue of few elements


• Queue is called FIFO(First In First Out) data structure.


Stack


1. Stack is a linear data structure.

2. In stack the insertion and deletion of elements is done by only one end called top.

3. For searching the graph using depth first search using non recursive routine, the stack is used.

4. For handling the recursive calls, stack is used.

5. Stack is called LIFO, Last in First Out data structure.

Rear

1. Queue is a linear data structure.

2. In queue, the element is inserted by one end called rear and the element is deleted by other end called front.

3. For searching the graph using breadth first search manner using non recursive routine, the queue is used.

4. The operating system makes use of queue data structure for storing the jobs that are ready for execution and are waiting for acquiring the resources.

5. Queue is called FIFO, First In First Out data structure.

 

Reveiw Question

1. What is Queue? Explain by comparing with stack.

 

Data Structures using C PlusPlus: Chapter 4: Stacks and Queues : Tag: Data Structure, C++ Programing : Data Structures using C++ Program - Introduction to Queues


Data Structures using C PlusPlus: Chapter 4: Stacks and Queues



Under Subject


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Electron Devices

EC25C01 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Circuits and Network Analysis

EC25C02 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Engineering Drawing - Laboratory

ME25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Data Structures using CPlusPlus - Laboratory

CS25C05 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Devices and Circuits Laboratory

EC25C03 2nd Semester ECE Dept | 2025 Regulation | 2nd Semester 2025 Regulation