[Geeks for Geeks] Full binary tree

Full binary tree

Given a Binary Tree. Check whether the Binary tree is a full binary tree or not.

  • Time : O(n)
  • Space : O(1)
1
2
3
4
5
6
bool isFullTree (struct Node* root)
{
if(!root->left and !root->right) return true;
if(!root->left or !root->right) return false;
return isFullTree(root->left) and isFullTree(root->right);
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/05/20/PS/GeeksforGeeks/full-binary-tree/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.