What is a Queue?
A Queue is a data structure that follows the rule:
FIFO → First In, First Out
That means the element that goes in first, comes out first — like a line at a ticket counter .
Enqueue
Enqueue means adding an element to the end of the queue.
Example:
Queue = [A, B]
If we enqueue C,
→ Queue becomes [A, B, C]
You are pushing C to the end.
Dequeue
Dequeue means removing the element from the front of the queue.
Example:
Queue = [A, B, C]
If we dequeue,
→ A is removed, and now Queue = [B, C]
| Concept | Data Structure | Example analogy | Used in |
| Queue (FIFO) | First In, First Out | Like people standing in a line for tickets – first person in goes first | BFS |
| Stack (LIFO) | Last In, First Out | Like a stack of plates – the last one kept is picked first | DFS |
Common Concepts to Introduce Before BFS/DFS
Before explaining, remind them:
| Concept | Meaning |
| State | A possible situation in the problem space |
| Start State | The node from where search begins |
| Goal State | The desired destination or solution |
| Path | Sequence of actions from start to goal |
| Frontier | List of nodes generated but not yet expanded |
| Explored Set | Nodes already expanded (visited) |
Breadth-First and Depth-First Search
These two are the basic Uninformed Search algorithms —
meaning they don’t use any heuristic or prior knowledge.
They simply explore the search space systematically.
Both BFS and DFS are fundamental algorithms used to explore or traverse trees and graphs.
In AI, they are used by problem-solving agents to find a path from a start state to a goal state.
