# Breadth First Traversal

## 1.Introduction

* What we interest is the whole ways to traversal binary tree
  * They very based on the order in which the nodes are accessed
* Bread First: visit on the nodes of a same level before moving on to the next level
* Depth First: reach into a tree as deep as possible get to a leaf

## 2.Breadth First Traversal

* 1.Start from the root node and add it to a queue
* 2.Dequeue and process the queue
  * Add it's left and right child to the tree
* 3.Continue as long as the queue is not empty


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jenhsuan.gitbook.io/algorithm/algorithms-in-a-nutshell/breadth-first-traversal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
