# Connect nodes at the same level in a binary tree

### PSEUDO ALGORITHM (Breadth first search approach)

We will use the same algorithm discussed in level-order-breadth-first-search-or-zig-zag-traversal-of-a-binary-tree with slight modification.

- Create an empty queue
**q** - Initialize roots height = 0; Enqueue
with the root node**q** - Loop while queue is not EMPTY
= dequeue**temp_node****q**- set
for every node**nextRight,** - Enqueue
’s children (first left then right children) to**temp_node**with relevant height**q**

### Solution