Nice video , just a minor correction : print root node first and then pass root's left to the print_left function . Otherwise it will fail for a tree having only right nodes.
this is a very great explanation, I appreciate all of your videos. a small thing 1. root needs to be dealt with independently before process left and right subtree
Hi Vivekanand, very clear explanation..Thanks. One request, could you please also mention some use cases (applications) of each of the traversals? This would motivate the viewers.
in the left tree recursion ,if e finishes the recursion stack then after some time it go back to C and from C it look ,it's have right subtree or not ,it have so it add C again
Nice video , just a minor correction : print root node first and then pass root's left to the print_left function .
Otherwise it will fail for a tree having only right nodes.
The way he says Hello friends itself takes my anxiety away.. Thank you for your efforts.
Just can't tell , how good you are ! Your videos have been really helpful for me in preparing for data structures interviews..! :)
Your explanation is nice... but if the tree is skewed it will print the boundary elements multiple times.
true
Sir just want to say thank you for this wonderful video. You are OP sir...........
this is a very great explanation, I appreciate all of your videos.
a small thing
1. root needs to be dealt with independently before process left and right subtree
You are genius!! Thank you so much for a simple explanation
very well explained sir, thank you for detailed explanation
Hi Vivekanand, very clear explanation..Thanks. One request, could you please also mention some use cases (applications) of each of the traversals? This would motivate the viewers.
can you make a series on solving the competitive programming question
Plz sir
Can I say that we need to find
1) left view of binary tree
2) right view of binary tree
3) find leaf nood of binary tree ?
no
@@RahulKashyap-yv5ox why?
Superb explanation!
really really good man!
Thanks, my python implementation:
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def __init__(self):
self.root = []
self.lb = []
self.rb = []
self.leaves = []
def boundaryOfBinaryTree(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if not root:
return root
self.root.append(root.val)
self.left_bdr(root.left)
self.leaf(root.left)
self.leaf(root.right)
self.right_bdr(root.right)
return self.root + self.lb + self.leaves + self.rb[::-1]
def left_bdr(self, root):
if root:
if root.left:
self.lb.append(root.val)
self.left_bdr(root.left)
elif root.right:
self.lb.append(root.val)
self.left_bdr(root.right)
def right_bdr(self, root):
if root:
if root.right:
self.rb.append(root.val)
self.right_bdr(root.right)
elif root.left:
self.rb.append(root.val)
self.right_bdr(root.left)
def leaf(self, root):
if root:
self.leaf(root.left)
self.leaf(root.right)
if not root.left and not root.right:
self.leaves.append(root.val)
Nice video,also please mention Time complexity for algorithm
in the left tree recursion ,if e finishes the recursion stack then after some time it go back to C and from C it look ,it's have right subtree or not ,it have so it add C again
Requires to change the position of print in print_right function.
In Right Boundary Condition,there is a correction. First we need to traverse to right child and then print the data.
You are really awesome dude
awsome sir
sorry sir ,
not working for right skew tree
very clear, thanks a lot!
return "very well explained" ;
wrong, Not work for skew trees
Sir there are many videos which are not added in playlist, Can you please add it
Thanks ....
the error lies using 2 "if" instead of 1 if and 1 else if
you need an extra condition to check if the tree is skewed otherwise the code will fail
Sir can you plz explain the M-way search tree ........
can u please provide quick sorting and merge sorting .
Sir can u explain rope data structure please
Plz solve postorder traversal from
Given in order,preorder
Sir your code is wrong it does not work for input (15,10,8,12,13,20,17,25)
its not printing in correct order, to get correct order,in right view all the printing statements should be just below of recursive calling function.
wrong code
you could have easily gone anticlockwise...this doesn't make much sense, sorry