Skip to content

Latest commit

 

History

History

Calculate Depth of A Full Binary Tree From Preorder

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given preorder of a binary tree, calculate its depth(or height) [starting from depth 0]. The preorder is given as a string with two possible characters.

  • ‘L’ denotes the leaf
  • ‘N’ denotes internal node

The given tree can be seen as a full binary tree where every node has 0 or two children. The two children of a node can ‘N’ or ‘L’ or mix of both.