Sparse Table Data Structure

Sdílet
Vložit
  • čas přidán 9. 06. 2024
  • Source code repository:
    github.com/williamfiset/algor...
    Video slides:
    github.com/williamfiset/algor...
    Website:
    www.williamfiset.com ===================================
    Practicing for interviews? I have used, and recommend `Cracking the Coding Interview` which got me a job at Google. Link on Amazon: amzn.to/3cvMof5
    A lot of the content on this channel is inspired by the book `Competitive Programming` by Steven Halim which I frequently use as a resource and reference. Link on Amazon: amzn.to/3wC2nix

Komentáře • 52

  • @thunderbolt8632
    @thunderbolt8632 Před 3 lety +17

    William tu to devta nikla re! Awesome 🔥

  • @ankitsinha9019
    @ankitsinha9019 Před 3 lety +3

    In first 2-3 minute u realize ur at right place for ur concept... awesome video:)

  • @alex85354
    @alex85354 Před 3 lety +6

    Shoutout to William and folks who contributed to this fantastic video.
    That being said, it's really a bummer that we're missing a video about a segment tree. Fenwick tree and Sparse table have its own advantages to select as primary datastructures, but when you need a point update for RMQ, then we definitely need to turn our heads to a segment tree :( The fact that other online sources aren't as easy to consume knowledge as your video, it would be much appreciated if you could make one in future!

    • @madhukiranattivilli2321
      @madhukiranattivilli2321 Před 2 lety +1

      What's RMQ? Range Min Query (or Range Max Query)?
      William Fiset says Fenwick Tree Point Update runs in O(log2(n)). Not good enough? Does a Segment Tree runs faster than this?
      I'm yet to learn about Segment Trees
      Please reply

  • @daumtto
    @daumtto Před 8 měsíci

    Thank you william from South Korea!! Please do not remove these awsome videos. It really helped me a lot and helping me now. You make complicated things easy. I thank you again.!!

  • @jaatharsh
    @jaatharsh Před 3 lety +2

    WOAH this is really awesome, I appreciate the hard work put behind creating such top-notch quality content.
    your explanation is amazing William, please do keep posting such video's.

  • @isaiasramirez7071
    @isaiasramirez7071 Před 3 lety +1

    This is pure gold William, thank you for such a great content. I've been struggling with an advanced problem in Hackerrank and your video series about trees just pointed me to the right direction. :D

  • @dotproduct763
    @dotproduct763 Před 4 lety +7

    Amazing explanation! I'm finally at peace with this concept 👌

  • @arsilvyfish11
    @arsilvyfish11 Před 2 lety

    Amazing explanantion, was really helpful, thank you to William and the other collaborators!

  • @JWong-hh5sr
    @JWong-hh5sr Před 4 lety

    Great video! Very clear and concise!

  • @ShubhamJoshishubhamjoshi

    Great explanation William . Can you post some videos on string matching algorithms also.

  • @jeevan999able
    @jeevan999able Před 2 lety

    Thank you for the great explaination

  • @joydeepbhattacharjee3849
    @joydeepbhattacharjee3849 Před 3 lety +2

    at 13:03 the equation of len should be len = r - l + 1 since r > l.

  • @flyingtiger123
    @flyingtiger123 Před 2 měsíci

    Fantastic video, concept well explained🎉🎉

  • @ShreyasNimishe
    @ShreyasNimishe Před 3 lety

    very clear and concise!

  • @youngjim7987
    @youngjim7987 Před 2 lety

    amazing presentation. I prefer first to watch some videos like these to grip the high-level idea and read the book to dive deeper.

  • @user-ls5zp3uf6e
    @user-ls5zp3uf6e Před 3 lety

    Thank you for the explanation

  • @uchennanwanyanwu2777
    @uchennanwanyanwu2777 Před 4 lety +3

    Thanks for the video. Finally, there's a good tutorial on Sparse tables. In your opinion, would you choose Sparse table over Segment trees

    • @WilliamFiset-videos
      @WilliamFiset-videos  Před 4 lety +6

      It depends. Sparse tables are great for fast range queries (although you do need nlogn memory). However, as soon as you need to be able to do any kind of point update or range update a segment tree is a good choice.

  • @mohitjaiswal5113
    @mohitjaiswal5113 Před 4 lety

    ThankYou so much for this !!

  • @BerArchegas
    @BerArchegas Před 2 lety

    Amazing video

  • @shameekagarwal4872
    @shameekagarwal4872 Před 4 lety +2

    why will i want to use a sparse table for functions without good overlap??
    i can use segment tree...

  • @ankitchoudhary197
    @ankitchoudhary197 Před měsícem

    wonderful

  • @lucien5112
    @lucien5112 Před rokem

    19:35 What happens with i is odd, and i/2 is a non-integer index of array log2

  • @arthurtapper1092
    @arthurtapper1092 Před 2 lety +1

    You should really bring the volume for your voice up, either via directly speaking to microphone louder or post processing as I have you turned up to 100% and if the room isn't completely quiet I cant hear you. If i play a song off of youtube at 5% it drowns you out even when your at 100% . Other than that great videos!

  • @naviesometimes9417
    @naviesometimes9417 Před 4 lety

    It's very helpful

  • @fdshdsfdsqq
    @fdshdsfdsqq Před 6 měsíci

    ty!

  • @mohammadyahya78
    @mohammadyahya78 Před 2 lety

    Thank you William. How did you compute last row at 16:00 please? I see that first element should be 2*-6*-6= -12*-6 = 72, but you wrote -12, why?

    • @WilliamFiset-videos
      @WilliamFiset-videos  Před 2 lety

      I computed -12 from the row above it from the cells at (row 1, col 0) and (row 1 col 2) for 2 * -6 = -12.

  • @l3zhang392
    @l3zhang392 Před rokem

    at 12:58, it should be len = R - L + 1 = 11 - 1 + 1, or?

  • @HimanshuDagar-kr7ct
    @HimanshuDagar-kr7ct Před 9 měsíci

    Just Wow!

  • @mersenne2486
    @mersenne2486 Před 2 měsíci

    awesome

  • @shikharsaxena9989
    @shikharsaxena9989 Před 3 lety +1

    why i+(1

  • @HelloWorld-tn1tl
    @HelloWorld-tn1tl Před 3 lety

    So, the time complexity is O(log(n)), and space complexity is O(n*log(n)) ?

  • @sahilguleria5505
    @sahilguleria5505 Před 4 lety

    In CascadingMinQuery(), for product example where we have to find product of all elements between [0,6]. In first iteration of for loop we will have [0, 0 + 2^2) in next iteration it will be [4, 4 + 2^2) which should be [4, 4 + 2^1) as discussed in product range query example.
    We will not be having the t[2][4] in sparse table. Then how to check that in the function

  • @prasannathapa1024
    @prasannathapa1024 Před 3 lety

    this is the best

  • @abhigupta6681
    @abhigupta6681 Před 4 lety

    Thanks for the tutorial. Can you please make video on lca queries as well?

  • @surajkulriya8536
    @surajkulriya8536 Před 4 lety

    great

  • @bismeetsingh352
    @bismeetsingh352 Před 3 lety

    Didnt understand how the table was constructed at 9:27

  • @netional5154
    @netional5154 Před 4 lety

    Thanks for the great video. At 15:25 the last segment goes to 16. I think it's an error.

    • @WilliamFiset-videos
      @WilliamFiset-videos  Před 4 lety

      Hi Netional, I think 15:25 is ok. I'm using the "half closed interval" notation [a, b) where a is inclusive, but b is not. Maybe I should have been more clear about that. As an example, the interval [3, 6) would mean {3, 4, 5}, not {3, 4, 5, 6}, and [4, 5) would just be: {4}

    • @netional5154
      @netional5154 Před 4 lety

      @@WilliamFiset-videos ah, I understand.

  • @boomboom-9451
    @boomboom-9451 Před 9 měsíci

    Why not using idempotency instead of overlap friendly term

    • @mersenne2486
      @mersenne2486 Před 2 měsíci +1

      not everyone is a boomer like you

  • @sourav_ghosh
    @sourav_ghosh Před 3 lety

    What if the array is not static? Can we use sparse table?

    • @sivaramd5637
      @sivaramd5637 Před 3 lety +1

      No, If the array is not static we need to update the sparse table which will take O(NlogN) time so, instead, you can use Fenwick tree or Segment tree (which takes only O(logN) time)

  • @algorithmimplementer415

    Volume is very low!

  • @vaibhavkumar6796
    @vaibhavkumar6796 Před rokem

    Dude the volume is so low