That null wala funda was genius 😘😘, If I were to do that, that would be trash and some kind of jugad, yours was elegant and now it's mine cause it wasn't yours either and maybe it was, it doesn't matter, that's how all this works, good things are always appreciated ❤️
Anuj Bhaiya is the most genius coder in YT along with Aditya bhaiya. I have never walked off from their videos feeling disappointed. The null approach intuition is solid!
thanks a lot bhaiya for making such kind of content for free. Before watching this video I was so confused in level order traversal but now I can explain and do code of level order blindly . Again Thanks a lot ❤❤❤
Bhaiya you are literally a genius. i had learnt a lot from you .I wish i could give your video more than one like😂.thanks for teaching and please make more problems solving videos of DSA topics😐
Is it possible to have binary tree where its left node is greater than itself... in your example (Time: 6:06) node with value "1" has a left child with value "2"?? BTW, I really like your explanations.. the way you cover the problem & come to a solution
Sir, I have gone through the tree concept and even watched your last 3 videos of tree and understood the approach and algorithm used to solve the various traversals and finding height, max node of tree. Still I am unable to take any new question on tree and solve it by my own. Please help me if somewhere I am lacking?? I will appreciate your response.
Hey Amit, it is a common thing that happens to everybody. All you need is to keep practicing more. Slowly you will be able to solve these kind of problems independently. Data Structures and algorithms are the most difficult part, just keep practcing.
i think the recursive solution wasn't correct, as we did a print for data ONLY when the level was 1, but what for other elements... there we didnt wrote any condition nor did we printed anything.. please correct me if i a am wrong.
logic of recursive solution is right.. because for the original root of tree required level is given as input.. eg(level 3).. level value decrease recursively and when it reaches level 1 pointer will be pointing to the required level element..
java code using queue- input- [3,9,20,null,null,15,7] Output [[3],[9,20],[15,7]] /*...........................................................................................*/ class Solution { public List levelOrder(TreeNode root) { List result= new ArrayList(); if(root==null) return result; Queue queue= new LinkedList(); queue.add(root); while(!queue.isEmpty()){ List level= new ArrayList(); int count= queue.size(); for(int i=0;i
That null wala funda was genius 😘😘, If I were to do that, that would be trash and some kind of jugad, yours was elegant and now it's mine cause it wasn't yours either and maybe it was, it doesn't matter, that's how all this works, good things are always appreciated ❤️
हर हर महादेव जय माँ भवानी जय श्रीराम जय माँ सीता जय हनुमानजी 🙏🙏🙏🙏🙏❤❤❤❤❤❤🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩
Anuj Bhaiya is the most genius coder in YT along with Aditya bhaiya. I have never walked off from their videos feeling disappointed. The null approach intuition is solid!
I understood it in 2 min thank you 😅😊
thanks a lot bhaiya for making such kind of content for free. Before watching this video I was so confused in level order traversal but now I can explain and do code of level order blindly . Again Thanks a lot ❤❤❤
thanks for clearing my concepts on level order traversal bhaiya !
Bhaiya you are literally a genius. i had learnt a lot from you .I wish i could give your video more than one like😂.thanks for teaching and please make more problems solving videos of DSA topics😐
Makes it super easy . Thank-you sir
Anuj Bhai, You are doing great. Keep it up brother
Thanks to Anuj bhaiya for this course 🥰🥰
bhaiya your way of teaching is so next well,so pls try to make the course complete ....it will help so many students
amazing yrr bhaiya ,your teaching skill is superb
Best teacher.
Very Well Explained, Thanks a lot
Sir this video was really helpful for me....thank you so much sir 🙏😊
amazing lecture 🙌
Your contents are awesome please post videos in English
You are real guru bro❣❣❣❣❣❣❣
Neat and easy explanation!
Samjha bhai samjh gaya 🤟
good and awesome video
Thank you it makes sense now.
Please upload at least 2 videos per week
love from Bangladesh.
keep going bhaiyya
Great!
Bhaiya is Back😀😀😀😀😀
brother , thanks
You're welcome!
Great vid bro. ♥
thank you bhaiya 😁
awesome way of teaching. great work
Thanks amazing video
Thank you bhaiya🙏👌
Bhaiya me Bhaiya ....Anuj Bhaiya!!!
One week main 3 video dalo bhaiya
Yes very easy explanation
bhaiya in the naive solution how to decide how many levels will be there in the tree so that we can run a for loop up to that?
bhai kdk yaar
Nice explanation..
This was a more difficult topic than ones before. But still very well explained.
nice explanation.. doing good job.
u r da bst
The method isEmpty() is undefined for the type Queue how to fix this
First method with O(n^2) is printing 7 and 9 first...so its going from bottom to up...! While queue method is printing from top to bottom.
is the breath first traversal? or depth first? or none?
bhaiya isme ek for loop bi ayega na for(int i = 0 ; i < queue.size() ; i++)
OP teacher
i am beginner to coding ,did anybody implemented this in hash map way which Anuj bhaiya explained in last
What is the recursive relation of level order traversal in form of T(n)?
if the queue is implemented with linked list then how will you handle the null node case (for every new line)
Hi bhaiya
So yeh aao ka dsa course java pe based hai??
Is it possible to have binary tree where its left node is greater than itself... in your example (Time: 6:06) node with value "1" has a left child with value "2"?? BTW, I really like your explanations.. the way you cover the problem & come to a solution
It's not a binary search tree . 👍
possible for such trees
first of all, drop your hair care routine.
For the recursive application the code is correct.. But i think not the explanation
Full stack developer full roadmap banaye na please sir please
Sir, I have gone through the tree concept and even watched your last 3 videos of tree and understood the approach and algorithm used to solve the various traversals and finding height, max node of tree.
Still I am unable to take any new question on tree and solve it by my own.
Please help me if somewhere I am lacking??
I will appreciate your response.
Hey Amit, it is a common thing that happens to everybody. All you need is to keep practicing more. Slowly you will be able to solve these kind of problems independently. Data Structures and algorithms are the most difficult part, just keep practcing.
greattttttttttttt
Bhai Android development in Java please
All those how want give like 👍
i think the recursive solution wasn't correct, as we did a print for data ONLY when the level was 1, but what for other elements... there we didnt wrote any condition nor did we printed anything.. please correct me if i a am wrong.
logic of recursive solution is right.. because for the original root of tree required level is given as input.. eg(level 3).. level value decrease recursively and when it reaches level 1 pointer will be pointing to the required level element..
@@nageshpoojary271 got it.. thank you
❤️❤️
with hashmap and arraylist
public void levelorder(Node root,Map m, Integer level)
{
if(root== null)
{
return;
}
if(m.containsKey(level))
{
ArrayList l = (ArrayList) m.get(level);
l.add(root.data);
}
else
{
ArrayList l = new ArrayList();
l.add(root.data);
m.put(level,l);
}
System.out.print(root.data+ " ");
levelordermy(root.left,m,level+1);
levelordermy(root.right,m,level+1);
}
Actually it's not queue I think ,it's stack , you are pushing and piping from front.
Pushing at the back, popping from front. It is a queue.
😅 ,oh right, I got confused from the code😅.
Isn't level order bfs?
Yep
No translation here?
Try this for HEIGHT calculation
public int height(Node root)
{
if(root == null){
return 0;
}
return (height(root.left) + 1) > (height(root.right)+1) ? (height(root.left) + 1) : (height(root.right) + 1);
}
thank me later
java code using queue-
input- [3,9,20,null,null,15,7]
Output
[[3],[9,20],[15,7]]
/*...........................................................................................*/
class Solution {
public List levelOrder(TreeNode root) {
List result= new ArrayList();
if(root==null) return result;
Queue queue= new LinkedList();
queue.add(root);
while(!queue.isEmpty()){
List level= new ArrayList();
int count= queue.size();
for(int i=0;i
❤❤