Fenwick Tree (Binary Index Tree) - Quick Tutorial and Source Code Explanation

Поділитися
Вставка
  • Опубліковано 30 лис 2024

КОМЕНТАРІ • 226

  • @antongeorgiev1089
    @antongeorgiev1089 3 роки тому +27

    Just read 3 articles without understanding what a Fenwick Tree was, and then I came here. Good work!

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

      Glad to hear that this video was helpful!

  • @rahulchaubey8988
    @rahulchaubey8988 4 роки тому +92

    Best explaination on FT so far i have seen..

    • @stablesort
      @stablesort  4 роки тому +3

      Thanks for the compliment! By the way, I am looking for a subject for the next video. So if you have any suggestions, please do let me know. Thanks!

    • @AshwaniYadavIIT
      @AshwaniYadavIIT 4 роки тому +1

      @@stablesort how about FFT algorithm to compute coefficients of polynomial p3 (where p3 = p1*p2; p1, p2, p3 are polinomials)

    • @stablesort
      @stablesort  4 роки тому +1

      @@AshwaniYadavIIT Thanks for an interesting suggestion! It's only been 20 years since I did anything with Fast Fourier transform =) I am adding it to my list. Cheers!

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

      @@stablesort It would be great if you could explain an algorithm to settle that account among n number of friends, given an array indicating the amount each person will receive (+) or has to give (-) to settle the account. I am not aware of any greedy algorithms to solve this

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

      @@neyyars Thanks for this suggestion. I'll add it to my list. Cheers!

  • @eug_gino
    @eug_gino 4 роки тому +30

    jesus christ, you are a very gifted teacher.

    • @stablesort
      @stablesort  4 роки тому +2

      WOW, thanks! I hope my other videos can live up to your expectations =)

  • @theRenjie
    @theRenjie 4 роки тому +55

    Every video of this guy is incredible... not sure how much time you have been putting into this work, kudos to you.

    • @stablesort
      @stablesort  4 роки тому +29

      Thanks for the encouragement, Renjie! Sometimes I do think that I am putting way too much time into these videos. But reading your comments feels like an adrenaline shot that keeps me going =)

  • @AbhishekVaid
    @AbhishekVaid 2 роки тому +15

    This is the best explanation of this concept anywhere on the internet. Amazing work.

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

    This man is saving me in Algorithms right now, goodspeed

  • @lambar0
    @lambar0 Рік тому +1

    Clear and concise intuition building with splitting array

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

    sir u dont know how much this video help me, appreciate it

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

    This is such a good explanation, thank you!

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

    Amazing. The best tutorial for BIT

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

      Thanks for the compliment!

  • @prakharnigam9757
    @prakharnigam9757 3 роки тому +20

    Your huge amount of effort that you put into these beautifully concise and crystal clear videos pays off by saving valuable time of thousands of students that learn from these super well made videos far greater than any other videos on UA-cam!! I hope this gem of a channel never stops producing such high quality content.

    • @stablesort
      @stablesort  3 роки тому +3

      Thank you for leaving such a wonderful compliment!

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

    I love this guy's video. Great work. Look forward to your next episode.

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

    You made is so simple to understand and write and recollect when needed

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

    Great video! Much better than those hour long video loaded with ads. Thank you!

  • @aiviskri
    @aiviskri 4 роки тому +1

    That's the best explanation of Fenwick tree I've found on the internet

    • @stablesort
      @stablesort  4 роки тому

      Thank you, I do appreciate your good words.

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

    This is the only video that explains how the Fenwick tree came into existence and why we have to travel with 2's complement, Thankyou!!

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

      Thanks for the good words!

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

    The best explanation on BIT I have ever seen!!
    Note at 4:07, the index 14 should be 15 - "2" = 13 rather than "1".

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

      Yeap, well noted - thanks for keeping me honest!

  • @stretch8390
    @stretch8390 5 місяців тому

    You are a fantastic educator. If you've ever watched competitive programming streams where they explain the answers you'll know being good at something and being able to explain something are two very different things. You have done the community quite a service in bringing such clear explanations!

  • @neyyars
    @neyyars 3 роки тому +3

    Very clear and concise. I was struggling to wrap my arms around this algorithm until I watched this video. Thank you so much!

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

      Thank for leaving a compliment! Glad to hear that it made sense =)

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

    This video is so incredible!! This is the most clear explanation of Fenwick Tree Ive seen so far! Thank you so much for this

  • @suryavaliveti8355
    @suryavaliveti8355 4 роки тому +4

    Thanks for the clear, concise and calm explanation. Your calmness makes it so much easier to learn :)

    • @stablesort
      @stablesort  4 роки тому +1

      Thank you, that's a very nice compliment, I do appreciate it. I'll do my best to keep it up. By the way, after publishing each video, I start looking for a new topic to cover. So if you have any suggestions, please do let me know. Thanks!

    • @suryavaliveti8355
      @suryavaliveti8355 4 роки тому +1

      @@stablesort thank you. I am still new to data structures and algorithms so I will definitely let you know as I come across more stuff.

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

    Thanks for the tutorial, a good accent, drawings & calm voice helps a lot in these videos, keep it up.

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

      Hehe, chuckling about the accent comment :)

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

      @@stablesort HOLY, the video is 2y old and you replied in 1h lol, thats the first time thats happened to me, also, lol

  • @jehdawg
    @jehdawg 4 роки тому +8

    Your videos are some of the best on UA-cam. Incredibly clear and such interesting algorithms. I love how you explain the simple version of an algorithm before explaining the final version, makes things so clear!

    • @stablesort
      @stablesort  4 роки тому +1

      Thank you for such a wonderful compliment!

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

    There’s so many videos on computer algorithms on the internet these days, but hardly any could match up to the caliber of your videos. I am not sure how you manage to make these high-quality videos continuously but I am very thankful you do and kudos to you from Taiwan!

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

      Hello from Los Angeles, and thank you for the kind words!

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

    You're the best, I'm learning so much about trees from your channel!!!

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

    Every second of this 9 mins video is worth watching. You sir really are a talented teacher, showing the source code makes the concept so much easier to comprehend.

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

    Insanely clear. Best explanation ever!

  • @SHUBHAMJHA-o3g
    @SHUBHAMJHA-o3g 2 місяці тому

    Best explanation of fenvik tree I have seen

  • @himachal8252
    @himachal8252 4 роки тому +6

    The way you are explaining man, your channel is gonna be huge, keep up the good work 👍🏻

    • @stablesort
      @stablesort  4 роки тому

      I do appreciate your vote of confidence!

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

    This is the best video on BIT. The visualization is truly amazing.

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

      Thanks for the compliment!

  • @kristopherbullinger213
    @kristopherbullinger213 Рік тому +1

    Excellent diagrams and animations. Thank you!

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

    Nicely done! Was reading a book on this and was having a hard time understanding the authors, thanks for this clear explanation

  • @Effulgence13
    @Effulgence13 4 роки тому +2

    This is the best Computer Science UA-cam channel I’ve come across. Thank you for addressing difficult concepts in a calm, easy to understand, and friendly manner.

    • @stablesort
      @stablesort  4 роки тому +1

      Wow, thank you for such a warm compliment!

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

    Awesome video! I had never heard of Fenwick trees, but now I know even how to implement one. Thanks!

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

    I have watched 30-40 min long videos trying to explain BIT - I didn't get the intuition until I watched this 9 min video! Kudos :) Looking forward to more material...

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

      Awesome, thank you! That was also my original motivation for making the tutorial - could not find one out there and so decided to make my own =)

  • @asdasdsal487
    @asdasdsal487 Рік тому +1

    Your explanation was amazing. Your narration and animation made it soo much easier to understand than other videos on this topic. I'm thankful for your efforts.

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

    Very clear explanation and awesome illustration! thank you!!

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

      You are very welcome! Thanks for leaving a good word!

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

    I can't be more thankful that I found this best ever video! Precise and concise, elegant!

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

      Wow, thank you! Glad to hear that it was helpful!

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

    The best video of Fenwick tree I've seen so far! Thx a lot !!!!

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

      My pleasure! Thanks for the compliment!

  • @vali8924
    @vali8924 4 роки тому +1

    Finally i understand how a binary indexed tree works.Thank you

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

    Damn..best explanation on YT

  • @SanjaySinghaniaIN
    @SanjaySinghaniaIN 6 місяців тому

    You are phenomenal. Your understanding of DS is remarkably deep and experienced! Much appreciation for sharing your painstakingly made absolutely lucid videos!! May God Bless You!!!

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

    The only source that can help me understand BIT in 10 minutes.

  • @aliaksandrhn1
    @aliaksandrhn1 3 роки тому +3

    Your diagram that starts at 3:01 explains it really clearly, much better than any tree-like depiction. I also liked your observation regarding the correlation between the rightmost bit set and the range that the given array cell covers. Additionally, while loop runs as many times as there are 1 bits in a binary representation of a number - also a great observation. A quality video and a great explanation, thank you, my Russian friend! Upvoted.

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

      Thank you for leaving such a detailed account of what you liked about the video! This is useful feedback for me; I do appreciate it. Cheers!

  • @ijaz2020
    @ijaz2020 4 роки тому +5

    This is an excellent video. Subscribed immediately. Please post videos regularly.

    • @stablesort
      @stablesort  4 роки тому +5

      Thanks for the words of encouragement! This kind of feedback really does motivate me to put time and effort into making new videos. By the way, I posted a new one just now (ua-cam.com/video/oAR_EYd8im0/v-deo.html). That one is more of a brain teaser/coding problem but it builds on the information from this video. I hope you like.

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

    You explained the difficult concept so crisply and intuitively sir. Thank you 🙏

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

      You are very welcome! Thanks for leaving such a wonderful compliment!

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

    Such perfect explanation! just WOW!

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

    Great stuff man - I rarely comment, but really have to tip my hat off to you. Thanks for putting all the effort in - it makes a difference :)

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

      Glad to hear it! Thanks for the compliment!

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

    excellent, clear, concise explanation. subbed!

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

      Thanks for the good words

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

    I just wanted to say, this is an extremely well made video and helped me a lot. Thank you

  • @SeyhunSaryldz
    @SeyhunSaryldz 4 роки тому +2

    Thank you so much for your efforts. As usual, your explanation is the best one so far imo.

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks for the good words, I do appreciate it 😊

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

    hey Andre, this video on Fenwick Tree is one of the most insightful videos I have seen on UA-cam on DSA. The explanation and the supporting visualization is incredibly intuitive. I keep coming back to this video to refresh my understanding on Fenwick Tree. Really appreciate the efforts you have taken to polish the visualization part (through PPT I felt). Please do continue teaching DSA like the way you do. Your channel will soar like the bar graph in you profile pic :)

  • @70da24
    @70da24 Рік тому

    First time on this channel, AND I LOVE IT! Thank you ,sir.

  • @amalroy7543
    @amalroy7543 4 роки тому +1

    Excellent.The best i could find for FT.Hope to see more videos from you on other topics as well.You really deserve more views.

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks a lot! More to come!

  • @maridavies3425
    @maridavies3425 4 роки тому +2

    Nice tutorial of a complex topic!

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks! More interesting episodes come out soon!

  • @AnilabhaBaral
    @AnilabhaBaral 4 роки тому +1

    Really a good explanation of Fenwick Tree in a very short time, kudos to you.

  • @mielewis3893
    @mielewis3893 4 роки тому +5

    This video is really helpful! Such a clear explanation of a difficult topic!

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks for the words of encouragement! I came across a few videos explaining Fenwick Trees that had good bits and pieces here and there. But none (that I could find) had a short and intuitive explanation from start to finish. Hence I made this video. Thanks for watching!

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

    Awesome video. Did not know we can populate Fenwick tree in linear time

  • @anusatyachoudhary7171
    @anusatyachoudhary7171 4 роки тому

    Excellent introduction of Fenwick Tree. Thanks Mr. Violentyev

    • @stablesort
      @stablesort  4 роки тому

      You are very welcome and thanks for the compliment!

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

    thanks for helping me gain an appreciation for this structure

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

    nice video, thanks for sharing knowledge

  • @izebit
    @izebit 4 роки тому +1

    Thanks for the clear and short explanation. Please keep making videos, you are good at that 👏

  • @genghisda236
    @genghisda236 4 роки тому +1

    Wao !! this channel only makes quality content.
    Awesome , why is there even 1 dislike in this video.
    These are some of the best explained videos on youtube.

  • @nhk_kakin_futuremvrcreator
    @nhk_kakin_futuremvrcreator 4 роки тому +2

    Good explanation, thank you.

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks for the compliment! Cheers!

  • @chinmayingle423
    @chinmayingle423 4 роки тому +1

    You are underrated man, thanks for the awesome tutorial :)

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

    Very nicely explained!

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

    the best explanation ever
    thank you

  • @joshyatharva
    @joshyatharva 4 роки тому +1

    Thank you for this video! It's really short and very informative. Waiting for more!

    • @stablesort
      @stablesort  4 роки тому

      Thanks, more videos are in the making! By the way, if you are interested in Fenwick Tree data structure, you may also enjoy this video on Segment Trees: ua-cam.com/video/xztU7lmDLv8/v-deo.html
      Cheers, and let me know which other topics you'd like me to cover!

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

    Thank you, Andre!

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

      You are very welcome, Ivan!

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

    Thank you! It is a very detailed and good animated video

  • @erikviking471
    @erikviking471 4 роки тому +1

    Your fan club is growing hombre...

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

    wow, great animations and to the point explanation. LOVE IT!!

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

    This is so easy to understand.. Thank you so much!

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

      Thanks! Glad to hear that it made sense :)

  • @ВоробійВіталій
    @ВоробійВіталій 2 роки тому +1

    Great explanation, thank you!

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

    Amazing content! This concept is now rooted in my brain and thanks to you.

  • @aryankhare9393
    @aryankhare9393 4 роки тому +2

    Thank you for helping me visualise it

    • @stablesort
      @stablesort  4 роки тому

      I am glad to hear that it helped!

  • @007sya
    @007sya Рік тому

    Very nice explanation! Good job

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

    Great video, thank you!

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

      I am glad to hear that you liked it!

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

      ​@@stablesort Sharing how to make the tree in linear time was helpful 😊

  • @compraker
    @compraker 4 роки тому +2

    Nicely explained!

    • @stablesort
      @stablesort  4 роки тому

      Thanks! I am glad you liked it.

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

    Thank you so much for the clear explanation.

  • @Nartymer
    @Nartymer 7 місяців тому +1

    WAHHHH! YOU HAVE NO IDEA HOW MUCH YOU HELPED MAN! I qualified for the national olympics of informatics in my country and binary index trees are often used to solve the given problems. It's the one piece of syllabus that I didn't quite understand. You helped me out immensely with this video, thank you!

    • @stablesort
      @stablesort  7 місяців тому

      WOW, good luck at the info olympics!

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

    Very good explanation, thank you very much!

  • @akashbhadouria6727
    @akashbhadouria6727 4 роки тому +1

    Thanks a lot,love from India.

  • @areej5732
    @areej5732 4 роки тому +1

    Great video!

    • @stablesort
      @stablesort  4 роки тому +1

      Thanks for the compliment!

  • @shourabhpayal1198
    @shourabhpayal1198 4 роки тому

    This channel is amazing

    • @stablesort
      @stablesort  4 роки тому

      Thanks for the compliment!

  • @rupjitchakraborty8012
    @rupjitchakraborty8012 4 роки тому +1

    This is soooooo gooooood, please make more videos on advanced DS

    • @stablesort
      @stablesort  4 роки тому

      Thanks, will do! By the way, any specific requests?

    • @rupjitchakraborty8012
      @rupjitchakraborty8012 4 роки тому

      @@stablesort Thanks for asking. Suffix Arrays and Trees, Segment Trees and Tries.

    • @stablesort
      @stablesort  4 роки тому

      @@rupjitchakraborty8012 Cool, those are good suggestions. Adding to my to-do list. Thanks!

  • @Xeeto
    @Xeeto 4 роки тому +1

    great video, thank you very much for the help.

    • @stablesort
      @stablesort  4 роки тому

      You are very welcome; I am glad you like it!

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

    masterfully done! 👏

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

    LEGEND

  • @g1ld
    @g1ld 4 роки тому +1

    Great explanation, thanks

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

    Very well Done!!

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

    This man is making ASMR for programmers

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

    Great video man!

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

    best visualization 🔥

  • @AlekseiMaide
    @AlekseiMaide 4 роки тому +1

    Amazing video, please keep up the good work! :)

    • @stablesort
      @stablesort  4 роки тому

      Thanks, will do! By the way, I am constantly prowling for new and interesting topics to cover. Please do let me know if there something that you'd like to see discussed on this channel. Cheers!

    • @AlekseiMaide
      @AlekseiMaide 4 роки тому

      @@stablesort I always struggle with proving greedy algorithms or even understanding if stumbled on the correct solution. If you happen to have any tips on how to approach greedy algorithms in general, that would be awesome.

    • @stablesort
      @stablesort  4 роки тому

      @@AlekseiMaide Yeah, proving correctness is always difficult... OK, are you thinking of greedy "shortest path in a graph" type of algorithms, like Bellman-Ford/Dijkstra's? There may be a few tutorials on how they operate, but may be not on how to prove them to be correct. Thanks for suggestion!

    • @AlekseiMaide
      @AlekseiMaide 4 роки тому +1

      ​@@stablesortI didn't have any specific algorithms in mind, but algorithm design in general for the group of problems where the sub-problems do not overlap and at every step its possible to make an optimal decision, yet it may be quite evasive. Something in terms of how to build a hypothesis, what to consider, intuition etc.
      (My main interest lies with competitive programming and I know for a fact that a lot of people struggle with greedy algorithmic challenges)
      Example of a trivial, yet somewhat evasive problem:
      codeforces.com/contest/282/problem/B
      Anyway, It's just an idea for a video, I proposed it because I figured you might have some interesting insights, if you don't, its totally fine, I will watch whatever you post :)

    • @AlekseiMaide
      @AlekseiMaide 4 роки тому +1

      Another topic I have really struggled finding good quality explanation for is "multi dimensional knapsack" problems.... 0/1 Knapsack is well covered... but not m-dimensional ones.

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

    Highly grateful for such a wonderful explanation _/\_

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

    Great video! Very clear explanation!
    By the way, when you say "last set bit", it is a bit ambiguous -- that is, you would need to clarify or define what you mean by "first" or "last" beforehand; maybe, "least significant set bit" or "right-most set bit" is less ambiguous.

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

    Awesome video. Thanks.

  • @saurabhbunty123
    @saurabhbunty123 14 днів тому

    really loved it ❤

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

    the video is very helpful anh fun , thanks for the video