Sparse Table Algorithm Range Minimum Query

Sdílet
Vložit
  • čas přidán 10. 06. 2024
  • / tusharroy25
    github.com/mission-peace/inte...
    github.com/mission-peace/inte...
    In computer science, a range minimum query (RMQ) solves the problem of finding the minimal value in a sub-array of an array of comparable objects. Range minimum queries have several use cases in computer science such as the lowest common ancestor problem or the longest common prefix problem (LCP).

Komentáře • 70

  • @sagarcs669
    @sagarcs669 Před 7 lety +60

    You should maybe stop asking for likes and shares. No one in their good sense will dislike this video. You truly understand the various phases of the algorithm one finds difficulty grasping and try to cover them in meticulous and illustrative examples. You deserve an award for being only one of the kind of CZcams Channel that has a whole lot of algorithm explanation. Awesome Sir!

  • @Nikita-xk9fc
    @Nikita-xk9fc Před 5 lety +9

    114k subscribers are very less for u.I haven't seen ny video with this level of explanation.superb xplanation

  • @jfcahoon
    @jfcahoon Před 8 lety +4

    Just wanted to say thank you for all the work you've put into these videos and explanations. Your work has helped me immensely and I really appreciate it.

  • @nitinjain1325
    @nitinjain1325 Před 6 lety

    khatarnak tarike se dhulai karte hai aap algorithms ki...use chupne ki jagah nahi milti.... u r great sir ji

  • @vineetsharma7287
    @vineetsharma7287 Před 3 lety

    Great Explanation! Your videos are helping dev community a lot.

  • @nguyenducvuanh48
    @nguyenducvuanh48 Před 5 lety

    Thank you sir! I would have given up on the problem without this video.

  • @aayushbaniyal2124
    @aayushbaniyal2124 Před 8 lety +1

    thanks for the videos... they were really helpful ... just know that because of you many students didn't got supply in algorithm course

  • @dvnsravan
    @dvnsravan Před 8 lety

    Thanks for the explanation Tushar!

  • @thesavagetrader3681
    @thesavagetrader3681 Před 7 lety

    Thanks sir for your great effort... very simple and easy explanation.

  • @imyashdeepsharma
    @imyashdeepsharma Před 8 lety

    That was very good explanation , cleared some of my doubts ! Thanks Tushar Sir :)

  • @user-mi5du2ez3b
    @user-mi5du2ez3b Před 8 dny

    I love this, great work sir

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

    Wow , such a clean explanation , Thank You 💙

  • @utuk123
    @utuk123 Před 8 lety

    Awesome video Tushar sir

  • @anhdungoan2679
    @anhdungoan2679 Před 5 lety +2

    This video is really useful, thank you very much, some people mistakenly thought the dislike button was a download button :D

  • @sarthakgaba1583
    @sarthakgaba1583 Před 3 lety

    Superbly Amazing! Thanks mate :)

  • @christy_yinyan8449
    @christy_yinyan8449 Před 7 lety +1

    Thank you so much! always the best!!!!

  • @AbhishekKumar-zz3ts
    @AbhishekKumar-zz3ts Před 8 lety

    sweet and simple explanation , keep it up :D

  • @pritommitchellrodrigues3724

    Thanks bhai, finally understood how it works. :D

  • @shivamchauhan3562
    @shivamchauhan3562 Před 4 lety

    Thank you. Very nice explanation.

  • @AmanGarg95
    @AmanGarg95 Před 8 lety +1

    Hi Tushar. If we were to do point updates at an index, then we would update all those entries at which the index in picture might contribute as a minimum to, right? This would be O(N logN) for N such point update queries. Am I correct in saying this?

  • @madhav3444
    @madhav3444 Před 2 lety

    Best explanation !

  • @RomanReigns-ds8hs
    @RomanReigns-ds8hs Před 5 lety

    thanks for the explanation.

  • @techstuff9830
    @techstuff9830 Před 2 lety

    Great one!

  • @hope-jh7bv
    @hope-jh7bv Před 3 lety

    Thank you so much sir.

  • @ZiadxKabakibi
    @ZiadxKabakibi Před 8 lety

    great as usual :D

  • @raj1307
    @raj1307 Před 5 lety

    great video sir :)

  • @sahilgarg750
    @sahilgarg750 Před 8 lety

    can we use sparse table for max min range query in a 2d array(matrix)?

  • @ShubhamJoshishubhamjoshi
    @ShubhamJoshishubhamjoshi Před 7 lety +2

    Thanks a lot :D could you please add one of LCA By RMQ also.

  • @abubakarismail5436
    @abubakarismail5436 Před rokem

    Weldone bruh Thanks

  • @sushmitagoswami2033
    @sushmitagoswami2033 Před rokem

    while doing the range query, why are we moving by k after we find the min in [query_L, K]? Since, we have already calculated for 2^k number of elements?

  • @uNabL3
    @uNabL3 Před 5 lety

    Thank you!

  • @RomanReigns-ds8hs
    @RomanReigns-ds8hs Před 5 lety

    for range queries problems. which algorithm would be better?

  • @yuunpeeto8293
    @yuunpeeto8293 Před 7 lety

    many thanks!

  • @front-rud
    @front-rud Před rokem

    Thank you bro!

  • @harshitgangwar1426
    @harshitgangwar1426 Před 4 lety

    good explanation

  • @immanuelsamuelgwu
    @immanuelsamuelgwu Před 2 lety

    Correct me If I'm wrong according to the sparse table being taught when i=4, j=0 in the first column, j will be 6 and i will be 7 and the min of both is 6 so the index of the 6 which is 1 should be returned right?

  • @mousatat7392
    @mousatat7392 Před 6 lety

    thank you very much

  • @s_cube8543
    @s_cube8543 Před 4 lety

    Explanation of pseudo code at the end is what i love most in your videos.. literally it saved hours of my effort for understanding how this algos work.. and all these bcz u put days of effort into building this awesome videos. Such clean and clear explanations with examples. Thank you sooo much!! Hats off to you.
    Please keep uploading more. Also if possible put links to some problems related to this algos to practise. Thanks once again!

  • @techgianttechyforever
    @techgianttechyforever Před 2 lety

    thanks a lot sir :)

  • @umangmalhotra1222
    @umangmalhotra1222 Před 7 lety

    Hi tushar! what is the logic behind putting index of minimum numbers in table , you could have directly put the minimum value direct in the table.
    BTW nice video as always.

  • @serhiypidkuyko4206
    @serhiypidkuyko4206 Před 5 lety +1

    Hi Tushar.
    Thank you for your video.
    I think for your viewers would be useful to explain the main idea of the algorithm with a sparse table.
    And this is as following:
    any range-interval [u,v] to divide onto two intersecting intervals [u,u+2^k-1] and [v+1-2^k,v] of length 2^k
    these two intervals are intersecting because by choice: 2^k

  • @vaibhavsharma8150
    @vaibhavsharma8150 Před 7 lety

    thanku sir

  • @somnathgiri3245
    @somnathgiri3245 Před 6 lety

    good

  • @rajbansal787
    @rajbansal787 Před 3 lety

    respect++

  • @rahulbhati3079
    @rahulbhati3079 Před 4 lety

    can you upload some questions related to it

  • @ravinapit1625
    @ravinapit1625 Před 4 lety

    Nice explanation. But Plz use another marker

  • @syedashamimakter3231
    @syedashamimakter3231 Před 3 lety

    cout

  • @samprasdsouza6993
    @samprasdsouza6993 Před 4 lety

    is this MO's algo ??

  • @Ashley_montz
    @Ashley_montz Před 5 lety

    does anyone know which problem in leetcode this is ?

  • @bharatgulati8531
    @bharatgulati8531 Před 5 lety

    wanted to give a double like to the video. but alas youtube restricted me two just one like.

  • @Himanshu-ed3mf
    @Himanshu-ed3mf Před 3 lety +3

    Important point : if we have to find out sum of elements in range [L, R], then sparse table will give time complexity O(log N) not O(1)

  • @techgianttechyforever
    @techgianttechyforever Před 2 lety

    Is it only me who listen keyboard smashing sound when he write something on board

  • @raghuramkarra15
    @raghuramkarra15 Před 7 lety +1

    number of columns should be floor(log2(n))

    • @RomanReigns-ds8hs
      @RomanReigns-ds8hs Před 5 lety

      why??

    • @ujjwalbansal1070
      @ujjwalbansal1070 Před 4 lety

      @@RomanReigns-ds8hs cp-algorithms.com/data_structures/sparse-table.html Read the Intuition part of the above link

  • @sgulugulu19
    @sgulugulu19 Před 5 lety

    Wouldn't it be more helpful if we store the elements directly..rather than their index

    • @dhruvreshamwala511
      @dhruvreshamwala511 Před 5 lety

      Exactly what I was wondering

    • @dhruvreshamwala511
      @dhruvreshamwala511 Před 5 lety +4

      Okay.. Got it.. The application of RMQ demands the storage of indices.. Because, usually, the minimum value is not just "Needed", it can also be updated.

  • @mayurkulkarni755
    @mayurkulkarni755 Před 7 lety +1

    The time complexity to query RMQ Sparse Table in your implementation is log*(n) (not to be confused with log(n), log*(n) is iterated logarithm) which can be reduced to O(1) by choosing 2 [L,R] values such that they cover all the nodes. Read this for more www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/#Lowest%20Common%20Ancestor%20(LCA)

  • @prudvim3513
    @prudvim3513 Před 7 lety +6

    Hi tushar, I think Segment tree takes O(n log(n)) space and time for pre processing. Not O(N)

    • @saikumark6327
      @saikumark6327 Před 6 lety

      the preprocessing time is o(nlogn)

    • @madankumarrajan1028
      @madankumarrajan1028 Před 6 lety +1

      This is O(N) just the same way a heap construction algorithm takes O(N).

    • @malharjajoo7393
      @malharjajoo7393 Před 5 lety

      @@madankumarrajan1028 Can you elaborate ? From my understanding, the heap construction algorithm time complexity is not very straight-forward to understand.
      Also, segment tree should be O(nlogn) according to me, since we use divide and conquer and then sum (in case of Range sum queries) the two child node values.

  • @samiulislamdurjoy
    @samiulislamdurjoy Před rokem

    G 17:23

  • @yeeroj
    @yeeroj Před 4 lety +1

    Tushar bhai angrejo ki tarah English kyun bol rhe ho.....indian style English bol lo

  • @ShubhamKumar-rt8nb
    @ShubhamKumar-rt8nb Před 4 lety +1

    first of all you should explain the logic or why we are doing something