/binary-tree-level-order-traversal-dojo

in level order traversal, we visit the nodes level by level from left to right

Primary LanguageCGNU General Public License v3.0GPL-3.0

This is a HackerRank challenge:

https://www.hackerrank.com/challenges/tree-level-order-traversal/problem

Binary Tree Level Order Traversal

From a pointer to the root of a binary tree, in level order traversal, we visit the nodes level by level from left to right.

Input Format:

The first line contains an integer n, the number of nodes in the tree.

Next line contains n space separated integer where i integer denotes node[i].data.

Sample Input:

6
1 2 5 3 6 4

Which are arranged in the tree as:

 1
  \
   2
    \
     5
    /  \
   3    6
    \
     4 

Sample Output:

1 2 5 3 6 4

Binary Search Tree Reference

In a binary search tree, all nodes on the left branch of a node are less than the node value. All values on the right branch are greater than the node value.