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

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 225

  • @antongeorgiev1089
    @antongeorgiev1089 3 года назад +25

    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 года назад +89

    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 3 года назад +1

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

    • @stablesort
      @stablesort  3 года назад +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 года назад +29

    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 года назад +54

    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 года назад +28

      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 года назад +14

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

  • @lambar0
    @lambar0 Год назад +1

    Clear and concise intuition building with splitting array

  • @jimhuertascanaza2744
    @jimhuertascanaza2744 2 года назад +1

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

  • @variksigurdsson1447
    @variksigurdsson1447 Год назад +1

    This man is saving me in Algorithms right now, goodspeed

  • @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 RUclips!! 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!

  • @gabrielxu2087
    @gabrielxu2087 3 года назад +2

    Amazing. The best tutorial for BIT

    • @stablesort
      @stablesort  3 года назад

      Thanks for the compliment!

  • @OckeDFreestyler
    @OckeDFreestyler 7 месяцев назад +1

    This is such a good explanation, thank you!

  • @stretch8390
    @stretch8390 4 месяца назад

    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!

  • @JuranHuang
    @JuranHuang 2 месяца назад

    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.

  • @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

  • @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!

  • @jehdawg
    @jehdawg 4 года назад +8

    Your videos are some of the best on RUclips. 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 2 года назад +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  2 года назад

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

  • @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 =)

  • @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!

  • @Effulgence13
    @Effulgence13 4 года назад +2

    This is the best Computer Science RUclips 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!

  • @changningli4107
    @changningli4107 2 года назад +2

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

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

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

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

  • @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!

  • @SanjaySinghaniaIN
    @SanjaySinghaniaIN 5 месяцев назад

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

  • @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

  • @nicholaswei5307
    @nicholaswei5307 3 года назад +1

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

  • @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!

  • @kristopherbullinger213
    @kristopherbullinger213 Год назад +1

    Excellent diagrams and animations. Thank you!

  • @MrAvadha1
    @MrAvadha1 3 года назад +2

    hey Andre, this video on Fenwick Tree is one of the most insightful videos I have seen on RUclips 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 :)

  • @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 =)

  • @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!

  • @gezhi9420
    @gezhi9420 3 года назад +1

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

    • @stablesort
      @stablesort  3 года назад

      Thanks for the compliment!

  • @ragas1999
    @ragas1999 3 года назад +1

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

  • @vali8924
    @vali8924 4 года назад +1

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

  • @SHUBHAMJHA-o3g
    @SHUBHAMJHA-o3g Месяц назад

    Best explanation of fenvik tree I have seen

  • @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

  • @mridularao6449
    @mridularao6449 2 года назад +1

    Such perfect explanation! just WOW!

  • @elliegu274
    @elliegu274 3 года назад +1

    Insanely clear. Best explanation ever!

  • @purplebunny6962
    @purplebunny6962 3 года назад +1

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

  • @ciachn
    @ciachn 2 года назад +2

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

  • @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!

  • @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 (ruclips.net/video/oAR_EYd8im0/видео.html). That one is more of a brain teaser/coding problem but it builds on the information from this video. I hope you like.

  • @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!

  • @shivamjaiswal2742
    @shivamjaiswal2742 2 года назад +2

    Damn..best explanation on YT

  • @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!

  • @yamaan93
    @yamaan93 10 месяцев назад

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

  • @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!

  • @anusatyachoudhary7171
    @anusatyachoudhary7171 4 года назад

    Excellent introduction of Fenwick Tree. Thanks Mr. Violentyev

    • @stablesort
      @stablesort  4 года назад

      You are very welcome and thanks for the compliment!

  • @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!

  • @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 😊

  • @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!

  • @70da24
    @70da24 Год назад

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

  • @qcqe
    @qcqe Год назад

    thanks for helping me gain an appreciation for this structure

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

  • @AnilabhaBaral
    @AnilabhaBaral 4 года назад +1

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

  • @nabidulalam6956
    @nabidulalam6956 3 года назад +1

    excellent, clear, concise explanation. subbed!

    • @stablesort
      @stablesort  3 года назад +1

      Thanks for the good words

  • @hj2931
    @hj2931 2 года назад +1

    nice video, thanks for sharing knowledge

  • @evgenyfedorenko953
    @evgenyfedorenko953 11 месяцев назад

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

  • @izebit
    @izebit 4 года назад +1

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

  • @nhk_kakin_futuremvrcreator
    @nhk_kakin_futuremvrcreator 3 года назад +2

    Good explanation, thank you.

    • @stablesort
      @stablesort  3 года назад +1

      Thanks for the compliment! Cheers!

  • @maridavies3425
    @maridavies3425 4 года назад +2

    Nice tutorial of a complex topic!

    • @stablesort
      @stablesort  4 года назад +1

      Thanks! More interesting episodes come out soon!

  • @Nartymer
    @Nartymer 6 месяцев назад +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  6 месяцев назад

      WOW, good luck at the info olympics!

  • @subhasreepatro7073
    @subhasreepatro7073 2 года назад +1

    Very nicely explained!

  • @nikitapodshivalov3573
    @nikitapodshivalov3573 2 года назад +1

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

  • @aryankhare9393
    @aryankhare9393 4 года назад +2

    Thank you for helping me visualise it

    • @stablesort
      @stablesort  4 года назад

      I am glad to hear that it helped!

  • @elmoad2055
    @elmoad2055 3 года назад +1

    the best explanation ever
    thank you

  • @RishinderRana
    @RishinderRana 2 года назад

    Amazing content! This concept is now rooted in my brain and thanks to 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: ruclips.net/video/xztU7lmDLv8/видео.html
      Cheers, and let me know which other topics you'd like me to cover!

  • @chinmayingle423
    @chinmayingle423 4 года назад +1

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

  • @ВоробійВіталій
    @ВоробійВіталій 2 года назад +1

    Great explanation, thank you!

  • @ullas2101
    @ullas2101 3 года назад +1

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

  • @goncharivan
    @goncharivan 3 года назад +1

    Thank you, Andre!

    • @stablesort
      @stablesort  3 года назад

      You are very welcome, Ivan!

  • @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 :)

  • @erikviking471
    @erikviking471 4 года назад +1

    Your fan club is growing hombre...

  • @kephasher3641
    @kephasher3641 3 года назад +1

    Amazing video!

    • @stablesort
      @stablesort  3 года назад

      Thanks for leaving a compliment!

  • @pangning3163
    @pangning3163 2 года назад

    Thank you so much for the clear explanation.

  • @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 😊

  • @marciodojr
    @marciodojr Год назад

    Very good explanation, thank you very much!

  • @akashbhadouria6727
    @akashbhadouria6727 4 года назад +1

    Thanks a lot,love from India.

  • @compraker
    @compraker 4 года назад +2

    Nicely explained!

    • @stablesort
      @stablesort  4 года назад

      Thanks! I am glad you liked it.

  • @007sya
    @007sya Год назад

    Very nice explanation! Good job

  • @Xeeto
    @Xeeto 3 года назад +1

    great video, thank you very much for the help.

    • @stablesort
      @stablesort  3 года назад

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

  • @itsahandle
    @itsahandle 2 года назад

    This man is making ASMR for programmers

  • @GubenkovED
    @GubenkovED Год назад

    masterfully done! 👏

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

  • @sachinfulsunge9977
    @sachinfulsunge9977 2 года назад +1

    Very well Done!!

  • @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!

  • @faizKhan-uv2dl
    @faizKhan-uv2dl 3 года назад +2

    Educational question: (Love the video, just curiosity)
    Although this video has less views, likes and comments than other related fenwick tree videos but somehow searching "fenwick tree" this is on top of the search list.
    How does youtube algorithm knows that this is the best video on this subject? Apart from basic things like, engagement on this video, the right keywords etc how do they find out? Did they watch it as well?

    • @stablesort
      @stablesort  3 года назад

      Haha, good question. I doubt they watch more than a small fraction of the videos themselves. I also do not think they care about keywords and such. My guess is that they do "AB testing" and keep track of what people do after having seen the video. For example, is someone searches for "fenwick tree", watches the first video but then stops half way through and watches the next, that tells the algorithm that the 1st video wasn't all that great. This is all speculation, of course. The exact methodology is a guarded secret =)

    • @faizKhan-uv2dl
      @faizKhan-uv2dl 3 года назад

      ​@@stablesort thats a good explanation. But isn't clicking the like button a proof that they found the video useful? Betting against that number must have alot of good reasons.

    • @stablesort
      @stablesort  3 года назад

      @@faizKhan-uv2dl Right, right, clicking the Like button and especially subscribing are probably major indicators. I was just thinking of other ways of extracting information from views that didn't result in Like button click. Hey, if you know more on the subject, do let me know =)

    • @faizKhan-uv2dl
      @faizKhan-uv2dl 3 года назад +1

      @@stablesort i appreciate sharing your thoughts. I wouldn't know either, just thinking out loud.

  • @nischaljain8140
    @nischaljain8140 3 года назад

    Highly grateful for such a wonderful explanation _/\_

  • @siddharthmagadum16
    @siddharthmagadum16 2 года назад

    best visualization 🔥

  • @g1ld
    @g1ld 4 года назад +1

    Great explanation, thanks

  • @angkhoavo6305
    @angkhoavo6305 3 года назад +1

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

  • @simonvutov7575
    @simonvutov7575 Год назад

    Great video man!

  • @geck1204
    @geck1204 2 года назад

    Omg this data structure has been so mysterious to me, but your explanation really helped. Thank you so much for this video!!!

  • @alexpelagaggi
    @alexpelagaggi 2 года назад

    Awesome video. Thanks.

  • @harishtiet
    @harishtiet 3 года назад +1

    To reset the right most set bit can we also use N = N & (N-1) ?