Skip to content

Tanujain2206/Queue-using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Queue-using-Python

Queues

Queues are data structures in computer science that look like lists in Python where you can insert and delete items. A queue is like stacks where you can insert and delete items in a specific order, but unlike stacks that follow the principle of last-in-first-out data structures, queues follow the principle of last-in-first-out data structures where the first item added is the first item removed.

You can think of Queues data structures as a line of people waiting to buy tickets for a show. Here the first person in line is the first to buy the first ticket and so on. So we can say that the queue data structure in computer science simulates the real queue.

A queue is like arrays where we work with a length that is one greater than the index of the last element in the array. In queues, we use a similar approach. In the section below, I’ll walk you through implementing queues using the Python programming language.

Queues using Python

Below are the functions that a queue data structure provides:

  1. enqueue: it is used to insert a new item into the Queue.
  2. dequeue: it is used to remove an item from a queue.
  3. is_empty: it returns True if the queue is empty and returns false if the queue is not empty.
  4. size: as the name suggests, it returns the number of items in a queue.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages