Level Order Traversal Binary Tree | Binary Tree Level Order Traversal | DSAOne Course #59

Поділитися
Вставка
  • Опубліковано 3 лют 2025

КОМЕНТАРІ • 77

  • @gouravchouhan1790
    @gouravchouhan1790 3 роки тому +15

    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 ❤️

  • @divyrajverma8286
    @divyrajverma8286 Рік тому +6

    हर हर महादेव जय माँ भवानी जय श्रीराम जय माँ सीता जय हनुमानजी 🙏🙏🙏🙏🙏❤❤❤❤❤❤🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩🚩

  • @rosonerri-faithful
    @rosonerri-faithful 2 роки тому +10

    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!

  • @shreyashpatil4196
    @shreyashpatil4196 Місяць тому

    I understood it in 2 min thank you 😅😊

  • @carry_still_live
    @carry_still_live 2 роки тому

    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 ❤❤❤

  • @funcode-tw3cg
    @funcode-tw3cg Рік тому

    thanks for clearing my concepts on level order traversal bhaiya !

  • @shalumishra662
    @shalumishra662 2 роки тому +2

    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😐

  • @anshpandey14325
    @anshpandey14325 2 роки тому +1

    Makes it super easy . Thank-you sir

  • @AmitPrasadbangalore
    @AmitPrasadbangalore 3 роки тому +1

    Anuj Bhai, You are doing great. Keep it up brother

  • @modalauday5938
    @modalauday5938 Рік тому

    Thanks to Anuj bhaiya for this course 🥰🥰

  • @lalitkashyap8167
    @lalitkashyap8167 2 роки тому +1

    bhaiya your way of teaching is so next well,so pls try to make the course complete ....it will help so many students

  • @rohitmaurya5931
    @rohitmaurya5931 2 роки тому

    amazing yrr bhaiya ,your teaching skill is superb

  • @khageshbansal2400
    @khageshbansal2400 2 роки тому +1

    Best teacher.

  • @ayushigupta8633
    @ayushigupta8633 Рік тому

    Very Well Explained, Thanks a lot

  • @ashutoshsharma5912
    @ashutoshsharma5912 Рік тому

    Sir this video was really helpful for me....thank you so much sir 🙏😊

  • @snehakaur8946
    @snehakaur8946 3 місяці тому

    amazing lecture 🙌

  • @upskill-development
    @upskill-development 3 роки тому +2

    Your contents are awesome please post videos in English

  • @balavardhanreddy8581
    @balavardhanreddy8581 Рік тому

    You are real guru bro❣❣❣❣❣❣❣

  • @sarwat3552
    @sarwat3552 2 роки тому +1

    Neat and easy explanation!

  • @bpratikvinod8110
    @bpratikvinod8110 2 роки тому

    Samjha bhai samjh gaya 🤟

  • @sumairakiduniya7976
    @sumairakiduniya7976 3 роки тому +1

    good and awesome video

  • @kunalkheeva
    @kunalkheeva 2 роки тому

    Thank you it makes sense now.

  • @prajwalshetti9367
    @prajwalshetti9367 3 роки тому +2

    Please upload at least 2 videos per week

  • @fardilviews
    @fardilviews 3 роки тому +1

    love from Bangladesh.

  • @Ganesh-zo9vr
    @Ganesh-zo9vr 3 роки тому +1

    keep going bhaiyya

  • @pradip_patil292
    @pradip_patil292 4 місяці тому

    Great!

  • @arpanmaheshwari2290
    @arpanmaheshwari2290 3 роки тому +5

    Bhaiya is Back😀😀😀😀😀

  • @ManishKumar-ss4ks
    @ManishKumar-ss4ks Рік тому +1

    brother , thanks

  • @dipanshusingh
    @dipanshusingh 2 роки тому

    Great vid bro. ♥

  • @senseiKakashi07
    @senseiKakashi07 2 роки тому +1

    thank you bhaiya 😁

  • @nirmesh44
    @nirmesh44 3 роки тому

    awesome way of teaching. great work

  • @smit7688
    @smit7688 2 роки тому

    Thanks amazing video

  • @lokendrasingh9780
    @lokendrasingh9780 2 роки тому

    Thank you bhaiya🙏👌

  • @manshushivam295
    @manshushivam295 2 роки тому

    Bhaiya me Bhaiya ....Anuj Bhaiya!!!

  • @reenayadav8468
    @reenayadav8468 3 роки тому +2

    One week main 3 video dalo bhaiya

  • @nitishsingh3470
    @nitishsingh3470 3 роки тому

    Yes very easy explanation

  • @ayushmishra3340
    @ayushmishra3340 2 роки тому +1

    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?

  • @shubhampatil4631
    @shubhampatil4631 2 роки тому

    bhai kdk yaar

  • @toshalchaudhari6574
    @toshalchaudhari6574 3 роки тому

    Nice explanation..

  • @prannoyroy5312
    @prannoyroy5312 2 роки тому +3

    This was a more difficult topic than ones before. But still very well explained.

  • @nageshpoojary271
    @nageshpoojary271 3 роки тому

    nice explanation.. doing good job.

  • @hhcdghjjgsdrt235
    @hhcdghjjgsdrt235 2 роки тому

    u r da bst

  • @adityamore7471
    @adityamore7471 2 роки тому +1

    The method isEmpty() is undefined for the type Queue how to fix this

  • @ANSHULGUPTA880
    @ANSHULGUPTA880 Рік тому

    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.

  • @fireblade987
    @fireblade987 Рік тому

    is the breath first traversal? or depth first? or none?

  • @pinkkitty6553
    @pinkkitty6553 Рік тому

    bhaiya isme ek for loop bi ayega na for(int i = 0 ; i < queue.size() ; i++)

  • @shashwatkrishnashukla2284
    @shashwatkrishnashukla2284 3 роки тому +1

    OP teacher

  • @rohitmore7725
    @rohitmore7725 2 роки тому

    i am beginner to coding ,did anybody implemented this in hash map way which Anuj bhaiya explained in last

  • @nabihamalik2212
    @nabihamalik2212 Рік тому

    What is the recursive relation of level order traversal in form of T(n)?

  • @bossagent5010
    @bossagent5010 Рік тому

    if the queue is implemented with linked list then how will you handle the null node case (for every new line)

  • @subhajitmohanty8349
    @subhajitmohanty8349 3 роки тому +2

    Hi bhaiya

  • @mranjaan5193
    @mranjaan5193 2 роки тому

    So yeh aao ka dsa course java pe based hai??

  • @ajoysahu2998
    @ajoysahu2998 2 роки тому

    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

    • @10daysAgo
      @10daysAgo 2 роки тому +1

      It's not a binary search tree . 👍

    • @sarwat3552
      @sarwat3552 2 роки тому

      possible for such trees

  • @bhumikagupta1268
    @bhumikagupta1268 9 місяців тому +1

    first of all, drop your hair care routine.

  • @PurbaChakraborty-um8wt
    @PurbaChakraborty-um8wt 4 місяці тому

    For the recursive application the code is correct.. But i think not the explanation

  • @chauhansumit5486
    @chauhansumit5486 3 роки тому +1

    Full stack developer full roadmap banaye na please sir please

  • @amitmohapatra6022
    @amitmohapatra6022 2 роки тому +1

    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.

    • @shashankmarri1056
      @shashankmarri1056 2 роки тому

      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.

  • @Lifeofkashh31
    @Lifeofkashh31 2 роки тому

    greattttttttttttt

  • @nihalshah3572
    @nihalshah3572 3 роки тому +2

    Bhai Android development in Java please
    All those how want give like 👍

  • @DurgaShiva7574
    @DurgaShiva7574 3 роки тому

    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.

    • @nageshpoojary271
      @nageshpoojary271 3 роки тому +1

      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..

    • @DurgaShiva7574
      @DurgaShiva7574 3 роки тому

      @@nageshpoojary271 got it.. thank you

  • @nittinrana2277
    @nittinrana2277 3 роки тому

    ❤️❤️

  • @MrSourabhkumarjain
    @MrSourabhkumarjain 2 роки тому

    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);

    }

  • @4FALLEN8
    @4FALLEN8 2 роки тому

    Actually it's not queue I think ,it's stack , you are pushing and piping from front.

    • @AnujBhaiya
      @AnujBhaiya  2 роки тому +3

      Pushing at the back, popping from front. It is a queue.

    • @4FALLEN8
      @4FALLEN8 2 роки тому

      😅 ,oh right, I got confused from the code😅.

  • @MitraWithUSA
    @MitraWithUSA 3 роки тому +1

    Isn't level order bfs?

  • @sridharanv5841
    @sridharanv5841 2 роки тому

    No translation here?

  • @MrTabraiz961
    @MrTabraiz961 2 роки тому

    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

  • @KamleshSingh-ym3cl
    @KamleshSingh-ym3cl 2 роки тому +1

    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

  • @krishnadawalkar6999
    @krishnadawalkar6999 3 роки тому

    ❤❤