Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published