Contents

Toggle## Graph Parses and Tree Parses

## Breadth-first search / Deep search

BFS traverses the tree increasing the depth to the root.

BFS(Graph G, Node s): {f = CreateQueue (); f.stack (s); mark (s);whileno f.empty () s = f.pop (); print (s);foreach children t of s in Gyewt unmarked DO f.stack (t); mark (t);end ifend forend while}

## In-depth search: pre-order

In-depth algorithms are recursive. In the prefix path, we always traverse the left subtree before processing the right subtree.

- Check if the current node is empty or null.
- Displays the data portion of the root (or current node).
- Traverse the left subtree by recursively calling the preorder function.
- Traverse the right subtree by recursively calling the preorder function.

## In-depth search: in-order

The LNR traverses as far left as possible, and displays branches from left to right. This algorithm displays diagonals from bottom to top.

- Check if the current node is empty or null.
- Traverse the left subtree by recursively calling the in-order function.
- Displays the data portion of the root (or current node).
- Traverse the right subtree by recursively calling the in-order function.

## In-depth search: out-order

It is a diagonal navigation from top to bottom.

- Check if the current node is empty or null.
- Traverse the left subtree by recursively calling the post-order function.
- Traverse the right subtree by recursively calling the post-order function.
- Displays the data portion of the root (or current node).