🔥🔥 the best part is u actually explained so calmly like one by one. and explained how the output is actually coming with that algorithm for all cases if anything will be explained like this.. concepts gonna so easy
what will be the looping condition in line by line? If it's loop till queue is not empty then in the if condition p ==null, n the enqueue statement under it will make an infinite loop.
Awesome Videos!! I still think there are many missing like finding max element in binary tree using recursion and without recursion which indeed uses LOT. Can you also try to make videos on those topics
Hi ..very good explanation..but for left and right view how do I determine the node?for left view maybe the 1st node after each null..but for right view?
Using level by level (not in one line) For the left view: the first root node and then each node just after null. For left view: Any node just before null
Hope this help, but there is another simple version. # None version def horizon_level(root): if root is None: return queue = [] queue.append(root) queue.append(None) while len(queue) != 1: p = queue.pop(0) if p is not None: print(p.data) if p.left is not None: queue.append(p.left) if p.right is not None: queue.append(p.right) else: queue.append(None) return
really it is amazing and outstanding explanation If we want to communicate with you how can we do that ? we ,a group of students from turkey ,want to take a paid course online from you hopefully you could help us all the best
Amazing great algorithms
!!!Thank you for posting this. Awesome video as always. Keep up the good work!!
🔥🔥 the best part is u actually explained so calmly like one by one.
and explained how the output is actually coming with that algorithm for all cases
if anything will be explained like this.. concepts gonna so easy
love the way you are explaining the things, best ds tutorials
Awesome Teaching Sir... You made algorithms subject easy to understand. I will be always grateful to you.
thank you for step by step instructions. Makes a big difference in understanding until the end!
Excellent explanation Vivekanand!
Thank you sooo much man! No matter what anyone says you are awesome and the way you make things clear is amazing. Thanks again :)
Amazing explanation sir.
Really liked it👍👍🥳🥳
Program using above algorithm:
public static void LevelOrderTrversal(TreeNode root)
{
Queue q = new LinkedList();
q.add(root);
q.add(null);
int level = 1;
while(!q.isEmpty())
{
TreeNode temp = q.remove();
if(temp != null)
{
System.out.println("Level = " + level + " value = " +temp.val);
if(temp.left != null) q.add(temp.left);
if(temp.right != null) q.add(temp.right);
}
else
{
if(q.peek() == null) break;
q.add(null);
level++;
}
}
}
what will be the looping condition in line by line? If it's loop till queue is not empty then in the if condition p ==null, n the enqueue statement under it will make an infinite loop.
Thanks for the great explanation Vivekanand.
hats off keep it up and upload videos in same manner!!
thanks a lot!!
sir where is the code?
github.com/mission-peace/interview/blob/master/src/com/interview/tree/LevelOrderTraversal.java#L19
Outstanding explanation
very well explained. Thank you sir .
Awesome explanation
Very well explained sir
great explaination ... i was struggling to understand this
Glad to help you.
Now I did understand the algorithm on wikipedia. Thank you.
Superb explanation
Nice Explanation!!
Thank you 🙏
Clear and crisp explanation. But do it with code.
thankyou sir for awesome explation
Awsome logic bro👌
Very nicely explained 👍
Great explanation.
You are awesome brother. Better than G* i should say !
Very Nice and clear explanation sir :)
Man you're awesome seriously
very clear to understand .thanks
How can I store each level into an ArrayList? Not just printing them all sequential out.
For everybody who is seeking for the same answer. Here is the link:bit.ly/2HmIOm8
What's your return type look like?
Awesome Videos!! I still think there are many missing like finding max element in binary tree using recursion and without recursion which indeed uses LOT. Can you also try to make videos on those topics
Who is your guru? Great explaination...!
Excellent explanation. Mention the codes also. It would be useful.
Thankx sir, So level order traversal and BFS is same ?
great explanation sir
Awesome Sir
great video sir, thanks a lot
Hats Off Buddy....
You are awesome,Dear
Thank you
great work, man! cheers!
do you provide live coaching for interview preparation. ?
Thanks a lot for the video
If the tree node has value of type "int" , the Null solution for line by line traversal isn't gonna work.
You can enqueue -1 then
thank you much vivek!!!!
Good job Bro. Keep it up :)
Hi ..very good explanation..but for left and right view how do I determine the node?for left view maybe the 1st node after each null..but for right view?
for right view it will be the end node at each level...
Using level by level (not in one line)
For the left view: the first root node and then each node just after null.
For left view: Any node just before null
Thank you, Sir!
Hope this help, but there is another simple version.
# None version
def horizon_level(root):
if root is None:
return
queue = []
queue.append(root)
queue.append(None)
while len(queue) != 1:
p = queue.pop(0)
if p is not None:
print(p.data)
if p.left is not None:
queue.append(p.left)
if p.right is not None:
queue.append(p.right)
else:
queue.append(None)
return
thx
its really good
(Dequeue Print Enqueue ) untill queue is empty.
thank you so much
thank you!
There is much better and simple way to print level by level using recursive call collect items into map and then iterate level by level to print them
In case recursive function call is expensive , this method is suitable. The extra Queue memory is actually O(n) which is very less
thank you so much !!!!
Great video. Do you have code sample?
github.com/mission-peace/interview/blob/master/src/com/interview/tree/LevelOrderTraversal.java#L19
Hi @vivekanand thanks for explanatory videos.
Could you please cover trie data structures and there applications. Thanks in advance !
How do I check for consecutive null
inside if loop, check for next element of queue to be null and break out of while loop.
check the length of the queue if len == 1 then stop the while loop, cause only None in the queue
wonderful
osm. explanation
really it is amazing and outstanding explanation
If we want to communicate with you how can we do that ?
we ,a group of students from turkey ,want to take a paid course online from you
hopefully you could help us
all the best
superb.... :)
will u please implement the same in code
thank u
great job!
This is vey High Lebel thinking
thank you sir
Welcome Jayram,
❤️
where do i find the code?
nice..
sir plzz also provide code for this
Iska code.....
Everything is Good.Improve English Bro.(Just suggestion)
What's wrong about his English?
Explained logic is crystal clear.....He wouldn't be working for BPO.
Thank you sir