Zigzag (Spiral) Level Order Traversal of Binary Tree | 4 Methods Explained | Binary Trees

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

ความคิดเห็น •

  • @FitCoder
    @FitCoder  3 ปีที่แล้ว +4

    00:00 Introduction
    00:06 Zigzag traversal
    01:15 1.Zigzag traversal using recursion
    03:14 2.Zigzag traversal using stack and queue
    11:11 3.Zigzag traversal using 2 stacks
    16:14 4.Zigzag traversal using deque
    22:50 C++ Implementation

  • @devlead6114
    @devlead6114 3 ปีที่แล้ว +8

    Only video that has all the methods explained in a concise manner....hats off.

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      thank you :)

  • @vinod9988
    @vinod9988 3 ปีที่แล้ว +2

    thanks for explaining all the methods....most videos just explain one of the methods....you took time to explain all. cheers.

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      You're welcome!

  • @himanshidhamija9524
    @himanshidhamija9524 3 ปีที่แล้ว +2

    Thanks for making such detailed video. Really helpful!

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      Glad you enjoyed it!

  • @codingninja3123
    @codingninja3123 3 ปีที่แล้ว +1

    I like the two stack approach....that was interesting. Thanks for sharing.

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      Glad you enjoyed it

  • @virendrakumarchoudhary9120
    @virendrakumarchoudhary9120 3 ปีที่แล้ว +1

    Sir I think in 3rd approach(2 stack) , the first while condition should have && operator instead of || operator. Because at end both the stack becomes empty , so 1st while condition remain always true due to s2.empty() gives always true. It gives TLE.

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว +1

      Right. Thanks for pointing out. ! was missing in the while statement. Fixed it.
      github.com/fit-coder/fitcoderyoutube/blob/master/tree/zigzag_level_order_traversal_two_stacks.cpp

  • @abdelmalek9004
    @abdelmalek9004 2 ปีที่แล้ว +1

    Hello sir
    For all of these algorithms, we must memories all of them or the most important thing is to understand the trick or the idea ?

    • @FitCoder
      @FitCoder  2 ปีที่แล้ว

      Idea is most important. Coz idea can be applied to different questions. That being said it's good to know solutions for the frequently asked questions.

    • @abdelmalek9004
      @abdelmalek9004 2 ปีที่แล้ว

      @@FitCoder
      For the interviews, you must write all the entire algorithm or you can tell the examiner only by the idea how we solve that problem ?

    • @FitCoder
      @FitCoder  2 ปีที่แล้ว

      Entire algorithm is required.

  • @pradeepaarti
    @pradeepaarti 3 ปีที่แล้ว +2

    sir can you make a whatsapp or insta group where everyone can ask doubts?

    • @FitCoder
      @FitCoder  3 ปีที่แล้ว

      For now, you can write doubts in the comment section. I will reply there surely.