A- Reverse level order traversal : # Pre -
order in BT
iteratevey :
Hint
Print
save
Prin "
→ son -
save
#
point during stack
push .
Hint then left
→
right call :
# Post order traverse iteratively :
A- In -
order
iteratively :
Hint → while
point stack pop .
# Left view of BT : #
Right view of BT :
recursion
# of
deft view of BT
iteratively : # Top view BT :
# Bottom view of Binary tree :
1st method e
method e
2nd
A-
Zig
-
Zag travel : # Check a BT is balanced or not :
vector <int> zigZagTraversal(Node* root)
{
vector<int> v;
vector<int> rev;
queue<Node*> q;
q.push(root);
int a = 1;
while(q.size()!=0)
{
int n = q.size();
if( a%2==1)
{
for( int i=0; i<n; i++)
{
Node* front = q.front();
rev.push_back(q.front()->data);
q.pop();
if(front->left)
{
q.push(front->left);
}
if(front->right)
{
q.push(front->right);
}
traverse of tree
}
#
Diagonal Binary :
}
else Iteration method
{
for( int i=0; i<n; i++)
{
Node* front = q.front();
rev.push_back(q.front()->data);
q.pop();
if(front->left)
{
q.push(front->left);
}
if(front->right)
{
q.push(front->right);
}
}
reverse(rev.begin(), rev.end());
}
for(int j=0; j<rev.size(); j++)
{
v.push_back(rev.at(j));
}
rev.clear();
a++;
}
return v;
}
cont current node ,
save Current → left on queue .
Go to current →
right .
A- Convert # Transform to Tree :
13T in
doubly linked list : 13T sum
It check a 13T is sum tree or not :
Alt check is ale leaf at same level :
p# Sum of longest path in a Bt :
# Given a binary tree and an integer K. Find the number of paths
in the tree which have their sum equal to K.
A path may start from any node and end at any node in the
downward direction.