Sparse Table Algorithm Range Minimum Query

  Рет қаралды 57,070

Tushar Roy - Coding Made Simple

Tushar Roy - Coding Made Simple

Күн бұрын

/ 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).

Пікірлер: 70
@sagarcs669
@sagarcs669 7 жыл бұрын
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 KZfaq Channel that has a whole lot of algorithm explanation. Awesome Sir!
@Nikita-xk9fc
@Nikita-xk9fc 5 жыл бұрын
114k subscribers are very less for u.I haven't seen ny video with this level of explanation.superb xplanation
@jfcahoon
@jfcahoon 8 жыл бұрын
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 6 жыл бұрын
khatarnak tarike se dhulai karte hai aap algorithms ki...use chupne ki jagah nahi milti.... u r great sir ji
@vineetsharma7287
@vineetsharma7287 3 жыл бұрын
Great Explanation! Your videos are helping dev community a lot.
@aayushbaniyal2124
@aayushbaniyal2124 8 жыл бұрын
thanks for the videos... they were really helpful ... just know that because of you many students didn't got supply in algorithm course
@nguyenducvuanh48
@nguyenducvuanh48 5 жыл бұрын
Thank you sir! I would have given up on the problem without this video.
@dvnsravan
@dvnsravan 8 жыл бұрын
Thanks for the explanation Tushar!
@thesavagetrader3681
@thesavagetrader3681 7 жыл бұрын
Thanks sir for your great effort... very simple and easy explanation.
@imyashdeepsharma
@imyashdeepsharma 8 жыл бұрын
That was very good explanation , cleared some of my doubts ! Thanks Tushar Sir :)
@ramakrishnachowdary3378
@ramakrishnachowdary3378 6 ай бұрын
Wow , such a clean explanation , Thank You 💙
@user-mi5du2ez3b
@user-mi5du2ez3b 12 күн бұрын
I love this, great work sir
@utuk123
@utuk123 8 жыл бұрын
Awesome video Tushar sir
@anhdungoan2679
@anhdungoan2679 5 жыл бұрын
This video is really useful, thank you very much, some people mistakenly thought the dislike button was a download button :D
@sarthakgaba1583
@sarthakgaba1583 3 жыл бұрын
Superbly Amazing! Thanks mate :)
@christy_yinyan8449
@christy_yinyan8449 7 жыл бұрын
Thank you so much! always the best!!!!
@AbhishekKumar-zz3ts
@AbhishekKumar-zz3ts 8 жыл бұрын
sweet and simple explanation , keep it up :D
@pritommitchellrodrigues3724
@pritommitchellrodrigues3724 4 жыл бұрын
Thanks bhai, finally understood how it works. :D
@shivamchauhan3562
@shivamchauhan3562 4 жыл бұрын
Thank you. Very nice explanation.
@AmanGarg95
@AmanGarg95 8 жыл бұрын
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 2 жыл бұрын
Best explanation !
@RomanReigns-ds8hs
@RomanReigns-ds8hs 5 жыл бұрын
thanks for the explanation.
@techstuff9830
@techstuff9830 2 жыл бұрын
Great one!
@hope-jh7bv
@hope-jh7bv 3 жыл бұрын
Thank you so much sir.
@ZiadxKabakibi
@ZiadxKabakibi 8 жыл бұрын
great as usual :D
@raj1307
@raj1307 5 жыл бұрын
great video sir :)
@ShubhamJoshishubhamjoshi
@ShubhamJoshishubhamjoshi 7 жыл бұрын
Thanks a lot :D could you please add one of LCA By RMQ also.
@sahilgarg750
@sahilgarg750 8 жыл бұрын
can we use sparse table for max min range query in a 2d array(matrix)?
@abubakarismail5436
@abubakarismail5436 Жыл бұрын
Weldone bruh Thanks
@sushmitagoswami2033
@sushmitagoswami2033 Жыл бұрын
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 5 жыл бұрын
Thank you!
@yuunpeeto8293
@yuunpeeto8293 7 жыл бұрын
many thanks!
@front-rud
@front-rud Жыл бұрын
Thank you bro!
@RomanReigns-ds8hs
@RomanReigns-ds8hs 5 жыл бұрын
for range queries problems. which algorithm would be better?
@harshitgangwar1426
@harshitgangwar1426 4 жыл бұрын
good explanation
@immanuelsamuelgwu
@immanuelsamuelgwu 2 жыл бұрын
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 6 жыл бұрын
thank you very much
@s_cube8543
@s_cube8543 4 жыл бұрын
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 2 жыл бұрын
thanks a lot sir :)
@serhiypidkuyko4206
@serhiypidkuyko4206 5 жыл бұрын
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
@umangmalhotra1222
@umangmalhotra1222 7 жыл бұрын
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.
@vaibhavsharma8150
@vaibhavsharma8150 7 жыл бұрын
thanku sir
@somnathgiri3245
@somnathgiri3245 6 жыл бұрын
good
@rajbansal787
@rajbansal787 3 жыл бұрын
respect++
@rahulbhati3079
@rahulbhati3079 4 жыл бұрын
can you upload some questions related to it
@ravinapit1625
@ravinapit1625 4 жыл бұрын
Nice explanation. But Plz use another marker
@syedashamimakter3231
@syedashamimakter3231 3 жыл бұрын
cout
@samprasdsouza6993
@samprasdsouza6993 4 жыл бұрын
is this MO's algo ??
@Ashley_montz
@Ashley_montz 5 жыл бұрын
does anyone know which problem in leetcode this is ?
@bharatgulati8531
@bharatgulati8531 5 жыл бұрын
wanted to give a double like to the video. but alas youtube restricted me two just one like.
@Himanshu-ed3mf
@Himanshu-ed3mf 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 2 жыл бұрын
Is it only me who listen keyboard smashing sound when he write something on board
@raghuramkarra15
@raghuramkarra15 7 жыл бұрын
number of columns should be floor(log2(n))
@RomanReigns-ds8hs
@RomanReigns-ds8hs 5 жыл бұрын
why??
@ujjwalbansal1070
@ujjwalbansal1070 4 жыл бұрын
@@RomanReigns-ds8hs cp-algorithms.com/data_structures/sparse-table.html Read the Intuition part of the above link
@sgulugulu19
@sgulugulu19 5 жыл бұрын
Wouldn't it be more helpful if we store the elements directly..rather than their index
@dhruvreshamwala511
@dhruvreshamwala511 5 жыл бұрын
Exactly what I was wondering
@dhruvreshamwala511
@dhruvreshamwala511 5 жыл бұрын
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 7 жыл бұрын
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 7 жыл бұрын
Hi tushar, I think Segment tree takes O(n log(n)) space and time for pre processing. Not O(N)
@saikumark6327
@saikumark6327 6 жыл бұрын
the preprocessing time is o(nlogn)
@madankumarrajan1028
@madankumarrajan1028 6 жыл бұрын
This is O(N) just the same way a heap construction algorithm takes O(N).
@malharjajoo7393
@malharjajoo7393 5 жыл бұрын
@@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 Жыл бұрын
G 17:23
@yeeroj
@yeeroj 4 жыл бұрын
Tushar bhai angrejo ki tarah English kyun bol rhe ho.....indian style English bol lo
@ShubhamKumar-rt8nb
@ShubhamKumar-rt8nb 4 жыл бұрын
first of all you should explain the logic or why we are doing something
Segment Tree Range Minimum Query
27:44
Tushar Roy - Coding Made Simple
Рет қаралды 270 М.
Sparse Table & RMQ (Range Minimum Query)
18:42
Errichto Algorithms
Рет қаралды 71 М.
She ruined my dominos! 😭 Cool train tool helps me #gadget
00:40
Go Gizmo!
Рет қаралды 30 МЛН
When Jax'S Love For Pomni Is Prevented By Pomni'S Door 😂️
00:26
WHY THROW CHIPS IN THE TRASH?🤪
00:18
JULI_PROETO
Рет қаралды 9 МЛН
Burst Balloon Dynamic Programming[Leetcode]
27:22
Tushar Roy - Coding Made Simple
Рет қаралды 102 М.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
Binary Search : Median of two sorted arrays of different sizes.
24:48
Tushar Roy - Coding Made Simple
Рет қаралды 538 М.
Sparse Table Data Structure
23:18
WilliamFiset
Рет қаралды 29 М.
System Design : Design a service like TinyUrl
24:10
Tushar Roy - Coding Made Simple
Рет қаралды 561 М.
Lazy Propagation Segment Tree
28:27
Tushar Roy - Coding Made Simple
Рет қаралды 94 М.
Lowest Common Ancestor (LCA) Problem | Eulerian path method
17:02
WilliamFiset
Рет қаралды 41 М.
Buy/Sell Stock With K transactions To Maximize Profit Dynamic Programming
29:09
Tushar Roy - Coding Made Simple
Рет қаралды 175 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 148 М.
She ruined my dominos! 😭 Cool train tool helps me #gadget
00:40
Go Gizmo!
Рет қаралды 30 МЛН