4.6 Optimal Binary Search Tree (Successful Search Only) - Dynamic Programming

Поделиться
HTML-код
  • Опубликовано: 21 фев 2018
  • This problem is a partial, considering only successful search.
    What is Binary Search Tree?
    What is Optimal Binary Search Tree?
    How to create Optimal Binary Search Tree by applying Dynamic Programming
    PATREON : www.patreon.com/bePatron?u=20...
    Courses on Udemy
    ================
    Java Programming
    www.udemy.com/course/java-se-...
    Data Structures using C and C++
    www.udemy.com/course/datastru...
    C++ Programming
    www.udemy.com/course/cpp-deep...

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

  • @raiakil
    @raiakil 5 лет назад +404

    Abdul Sir, I work for Microsoft in Redmond Seattle. I have 15 years industry experience, but I have never seen such crisp explanation of DP. Chained Matrix mult and this one with OST, is one of the best explanation videos on RUclips ever,

    • @Akaash449
      @Akaash449 2 года назад +8

      Hi , I am Saptarshi Rudra from India. I have a passion for working at Microsoft and a good grasp over DS and Algo and years of Software Development experience. I would really love if someone like you recommend me for a Software Developer / Engineer position. I have applied for these positions for the past 2 months, but yet to receive any call. So I would be extremely grateful if you recommend me.
      My full name is Saptarshi Rudra.
      Thanks.

    • @ArvindKumar-fv6mv
      @ArvindKumar-fv6mv 2 года назад +12

      @@Akaash449 waste of time bro he might have changed his mail I'd so only no response

    • @anubhavpandey7682
      @anubhavpandey7682 Год назад +3

      he told the formula to fill the table after filling the table..all the time i was thinking how he is filling.....so how can you say this is best......

    • @atharvameher5880
      @atharvameher5880 Год назад +4

      @@Akaash449 Why do people wanna work in foreign I don't get it? You guys don't like it here? Proximity to family and friends don't matter to you?

    • @Akaash449
      @Akaash449 Год назад +3

      @@atharvameher5880 please inform yourself before rashly posting a comment. Microsoft, Google and Amazon have local offices in the country in many states. Where is even your statement coming from!!

  • @fenggeliu4241
    @fenggeliu4241 5 лет назад +309

    For those who don't understand the formula here is an explanation. It took a while for me too.
    Everytime you try to add the nth node on to a tree with n - 1 nodes, you have to pick a root point k and k - 1 nodes on the left tree, n - k nodes on the right tree.
    k - 1 and n - k each as INDIVIDUAL TREE should already be calculated previously according to the table, so you just have to find where those are on the table which is at c[0, k - 1] and c[k, n]
    Look now we have the rank of 2 trees and 1 single root, to push the left or right tree into a sub tree you need add one level on each of their node therefore add the entire weight of the tree
    The combined tree with k as root have:
    Rank(k) = Rank(left) + Rank(left) + weight(left) + weight(right) + weight(root) = Rank(left) + Rank(right) + weight(0 - n)
    = c[0, k-1] + c[k, n] + w(0, n)

  • @eddiesengola4491
    @eddiesengola4491 6 лет назад +299

    You can see. He teaches with love, reveals everything that needs to be mastered. Thanks Abdul. You are the best.

  • @RoyalEXO_
    @RoyalEXO_ 4 года назад +20

    You are a life saver, sir! Honestly, you make this subject look so easy and fun! Hooked.

  • @rb_honest
    @rb_honest 11 месяцев назад +31

    Thank you, Sir 🙏

    • @abdul_bari
      @abdul_bari  11 месяцев назад +50

      Dear, check the amount once. I think, it’s by mistake.

  • @coolone5561
    @coolone5561 24 дня назад +1

    Abdul Sir, I am a 5 year experienced Software Engineer. I have Google interview coming up on June 10th. So I started watching your algorithm videos and reached this lecture. Although I found this playlist very late after referring to a number of resources, your videos are very effective and easy to understand..

  • @Diana-np5so
    @Diana-np5so 2 года назад +5

    such an amazing explanation of optimal binary search trees!!! thank you so much for making this video!

  • @hassansyed5661
    @hassansyed5661 5 лет назад +14

    You are a wonderful teacher. Thank you, so much for helping me to understand these concepts in an easy way.

  • @hrushikeshvazurkar
    @hrushikeshvazurkar 4 года назад +4

    Thank you Sir for the video. The effort you put in making these videos is really commendable.

  • @jaatharsh
    @jaatharsh 3 года назад +10

    Abdul Bari Sir (love) for ur passion to teach us, with every new video you raise the bar even higher,
    I cannot thank you enough for this, hope u always stay healthy & wealthy :)

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

    Great video so easy to understand , clear pronunciation and clear handwriting

  • @anasjamal7206
    @anasjamal7206 Год назад +27

    It's relatively impossible to not understand what you convey . You are a legend ❤️.
    For all concepts in DAA i watch your videos .
    First time when I watched your video on this concept i couldn't understand as I was bit hurried due to upcoming test in an hour .😁😁
    But now here I am again for the second time , watching this concept and understanding it properly .
    Note : for those of you who don't understand Abdul Bari sir , maybe you need to be relaxed and give some time to the video without any hurry . This is specially for those who come here an hour before exam 😂.

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

    tomorrow is my viva and i am here that makes u life saver thankuh so much sir

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

    You just saved my life in a Data Structure exam, thaks very much 😍😍😍

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

    Wt a teaching sir..... Really no one can say like u sir..... With out disturbance....super sirrr

  • @sashankyakkali3029
    @sashankyakkali3029 5 лет назад +1

    ur videos r great sir...thank u for saving us...gitam students love u a lot

  • @gabrielmachado146
    @gabrielmachado146 6 лет назад +19

    Sir, I have to thank you a lot for saving me. Great content and explanation! Please keep up the good work!

  • @chitnat
    @chitnat 2 месяца назад +1

    For the recurrence relation, it would be more appropriate to write C[i, j] (for i < j) as the min {C[i, k-1] + C[k+1, j]} + w(i, j) where i

  • @knoName5691
    @knoName5691 6 лет назад +10

    I have gone through few video lectures of ur's sir..Very qualitative, easily understandable..
    Thank you.. :-)
    Playlist is matching VTU syllabus..

    • @knoName5691
      @knoName5691 6 лет назад +4

      +Abdul Bari Yeah sir.. Visvesvaraya Technological University..
      Exams for my students will be in Jun-Jul

  • @AmanSharma-me7ho
    @AmanSharma-me7ho 5 лет назад +2

    Sir's explanation is great, i just love his explaining techniques.

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

    great video! Explain things so well!

  • @HimanshuSharma-us1gz
    @HimanshuSharma-us1gz 5 лет назад +10

    Sir I am from GGSIPU (Delhi), Today i hava ADA exam and I prepared only your videos, and kudos to your playlist thanku so much!

    • @ankushgarg2188
      @ankushgarg2188 5 лет назад +2

      Kesa gya bhai ?

    • @HimanshuSharma-us1gz
      @HimanshuSharma-us1gz 5 лет назад +1

      @@ankushgarg2188 Rula diya yaar, difficult exam aaya tha!

    • @HimanshuSharma-us1gz
      @HimanshuSharma-us1gz 5 лет назад +1

      @@abdul_bari Sir 100%, these videos contains even more, thanks sir for replying, you are legend, and god for us!

    • @naziyafirdoussayyed8491
      @naziyafirdoussayyed8491 5 лет назад +1

      @@abdul_bari Sir...ur videos are very helpful 😇 ur way of teaching, deep knowledge of the this subject 👏
      Lots of love and huge respect 😇
      From🇮🇳

  • @cipherwills7877
    @cipherwills7877 6 лет назад +2

    You are truly a saviour,
    Tysm.

  • @piyushverma826
    @piyushverma826 Год назад +4

    i never hated any subject until i encountered Design and analysis of algorithms. also my university prof who makes the ppr so difficult and calculative.

  • @softwareengineer8923
    @softwareengineer8923 11 месяцев назад +5

    In 6:35 it was actually 22.Also thanks for a great video!

  • @Rakeshrajeev94
    @Rakeshrajeev94 6 лет назад +3

    Sir, Thank you so much for the video. Best explanation I have seen. Expecting more videos.

  • @karthikadharmaraj1557
    @karthikadharmaraj1557 6 лет назад +2

    I like ur way of teaching... Ur teaching is very clear sir about the topic

  • @harekrishnamahto6512
    @harekrishnamahto6512 6 лет назад +1

    I want to salute u sir for your efforts in making such amazing videos. It made all my concepts clear. Thank you sir

  • @naklecha
    @naklecha 5 лет назад

    Thanks for telling us how the formula works :)))))))

  • @nadaashraf1771
    @nadaashraf1771 5 лет назад

    you're amazing thank you so much for your effort

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

    A very good explanation. Thank you.

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

    Thank you sir it's a very understandable example 🙏🙏

  • @fahadshajahan2554
    @fahadshajahan2554 Месяц назад +6

    Hemanth on fire 🔥🔥🔥

  • @dr.vinodkumarchauhan3454
    @dr.vinodkumarchauhan3454 6 лет назад +1

    Sir, first of all, thank you very much for the wonderful content.
    Sir, it looks like you have not covered some contents from Algorithms, which is generally part of the syllabus. So I request you to cover the following contents also:
    Lower-Bound Theory:
    Introduction to Algebraic problems, Introduction to lower bounds, Comparison Trees,Techniques for Algebraic problems, Some Lower Bounds on Parallel Computation

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

    Thank you sir, for your great explanation. 🙏🙏

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

    @7:46 when he said: this is the optimal binary search tree! I made dua for this teacher.

  • @srinivaskari
    @srinivaskari 16 дней назад

    Sir you have explained the concepts so well.

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

    If you are a faculty in our college we always rock in the exams Your lectures are Superb sir 👏👏👏👏👏👏👏🙏🙏🙏🙏

  • @charmingpetal
    @charmingpetal 28 дней назад +1

    14:45 top moment, thank you

  • @ryanp9441
    @ryanp9441 5 лет назад +1

    Thank you so much for the explanation! It helped me a lot!

  • @AnLaggy
    @AnLaggy 5 лет назад

    Thank finally I understand it :D

  • @lokeshagarwal6701
    @lokeshagarwal6701 5 лет назад +31

    The video is like explaining the steps involved but i need the reason behind why we are doing ot in that way?

  • @aniketnangare904
    @aniketnangare904 7 месяцев назад

    Your teaching is great sir

  • @ryanstobbe864
    @ryanstobbe864 6 лет назад

    This is the best explanation I have found on You tube thanks

  • @boris3484
    @boris3484 6 лет назад

    great content ! thank you

  • @helloworld3042
    @helloworld3042 6 лет назад +1

    Nice explaining sir

  • @syedmahasibali2324
    @syedmahasibali2324 5 лет назад

    It's some what difficult problem to solve but this video made it easy for implementing

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

    Thank you very much. You are a genius. 👍👍🔝🔝🙏🙏👌👌

  • @Afzalkhan-yw8eu
    @Afzalkhan-yw8eu 3 года назад +1

    Big Thanks sir ......you are awesome.

  • @girrajjangid4681
    @girrajjangid4681 Год назад +3

    We can also directly generate tree by taking max frequency key as an root.

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

      Does this work all the time?
      Btw tq for that, 😅

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

    강의 감사합니다~!!

  • @meimei1572
    @meimei1572 4 года назад +7

    I would've given up my final exams if you were not here.

  • @berylbose7006
    @berylbose7006 5 лет назад +2

    Hi Sir,
    Really Informative, great use of examples . I am able to grasp the content so well..
    Just a quick suggestion, could you also device the algorithm or pseudo-code at the end, to help us get a more generalized view on solving the problem.

    • @berylbose7006
      @berylbose7006 5 лет назад

      Maybe next time. Or Sir u can add like a Part-2 for this video

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

    Amazing explanation!!!! Thank you so much!

  • @manasakuncham4547
    @manasakuncham4547 5 лет назад +5

    sir,could you explain how to generate a tree from the data at the end?

  • @MrLucario69
    @MrLucario69 5 лет назад +3

    Thanks Abdul, you the real g, if you need a homie, hit me up

  • @nigarattar4079
    @nigarattar4079 5 лет назад

    Nice explanation sir aapke sabhi videos bahot hi ache se samjh ate hain thanks

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

    Very good teaching 😊

  • @sandeepkumar-ty3kt
    @sandeepkumar-ty3kt 4 года назад +14

    Formula = c[I,j]={c[I,k]+c[k+1,j]+weight}
    Where k values are
    C[0,3] then k values are 0,1,2
    Then I=0 and j=3
    Substitute the values
    C[0,0]+C[1,3]+12
    Hope it helps

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

      Why did u only took k=0,but k can be 1,2 also??

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

      @@naveen_kotha That was just a part of that example. Yes k can also be 1 and 2

    • @deepaksehrawat970
      @deepaksehrawat970 9 месяцев назад

      Thanks for formula

  • @donavarghese6273
    @donavarghese6273 5 лет назад +10

    wonderfully taught.
    but u should have explained formula in the start and not revealed it at the end.
    that wud have made it better

    • @rufusmcgee4383
      @rufusmcgee4383 3 месяца назад

      Totally agree, had me scratching my head the whole time.

  • @sfsyedfaisal
    @sfsyedfaisal 6 лет назад

    Dear sir, are you going to take session on data structure and advanced data structures like you give session on algorithm . It is wonderful.

  • @manujpande8544
    @manujpande8544 5 лет назад

    again great sir.

  • @prashant7622
    @prashant7622 4 года назад +21

    before you start filling the matrix , please mention what is the behind filling like that ..for example.....telling that j-i=1 but what is the motive of doing that because when i will get a problem i will not start thinking like first i-j=1 then i-j=2 ..in fact i will start thinking it practically why i need to do that then converting it into matrix .l have seen you explaining like this before also . al though everytime i am able to figure out why it is needed bt still start with the motive why we need to proceed like that.

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

    Good work!!

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

    I observe one thing in the above problem that consider the frequencies in descending order and then form binary search tree. We get answer(you need cost then find the cost from tree)

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

    Please clarify my query..
    1. when j-i =1 -> Here we calculated the cost for all the 4 keys (10, 20, 30 40)
    2. when j-i =2 -> Why do we only take these 3 combination (10, 20) (20, 30) (30, 40) only ??
    3. As we already know to select 2 keys out for keys is 4C2 => 6
    4. So why we dont consider (10, 40) (10, 30) (20 40)
    5. |||y for 3 pairs and so on ??
    Could you please clarify this point .. ?? Thanks in Advance..

  • @karansunchanakota6624
    @karansunchanakota6624 5 лет назад

    Explanation part was good, but as dint know the formula earlier it was a bit confusing in between...

  • @aradhyajain9575
    @aradhyajain9575 5 лет назад +9

    @14:45 how are you getting the values using formula.....and also please tell how u calculated it in brief? Sir.....thank you.....I am finding it very difficult to understand this part.

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

      same problem

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

      if any one knows pls replay

  • @paulz_san
    @paulz_san 6 лет назад +293

    How many engineers out here, give a like.

  • @Dhanunjayp-fz5cj
    @Dhanunjayp-fz5cj 5 лет назад +6

    6:32 answer is by adding the values 22

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

    just wow! it was great...

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

    Sir which books you have referred to gain this much knowledge ❤️

  • @yichizhang973
    @yichizhang973 5 лет назад +2

    Your explanation is great, but I was kind of confused about the 9:05, when you conduct j-i, I do not understand the meaning of j-i, and the meaning of l, what that expression stands for? and why we use 1 represent 10, 2 represent 20 and so on, if we use 4 represent 10 ,it is a different story.

  • @souravseal7262
    @souravseal7262 4 года назад +4

    a quick shortcut for exam or observation just add the corresponding element from the row and column u are supposed to find....
    for example u want to find
    c[0,3]=(0,0)+(3,1),(0,1)+(3,2),(0,2)+(3,3) hope u found the pattern...

  • @thinkandlearn7258
    @thinkandlearn7258 6 лет назад

    Great Content sir.

  • @ImSoumenMukherjee
    @ImSoumenMukherjee 5 лет назад +52

    6:32 How it came 18?? It will be 22.. Right?

  • @yuvaraj8188
    @yuvaraj8188 5 лет назад

    Tqqq sir..this video useful sir

  • @syedchand995
    @syedchand995 6 лет назад

    Great sir thnk u very much

  • @P_S_PATIL
    @P_S_PATIL Год назад +3

    first see the formla and then see it will be of great help 29:29

  • @hassanmahammad1135
    @hassanmahammad1135 6 лет назад

    superb ....explanation thank you and do more

  • @iiluffytaro4835
    @iiluffytaro4835 Год назад +2

    ABDUL BARI I LOVE YOU SO MUCH

  • @BanothAnusha-hv4qn
    @BanothAnusha-hv4qn 3 месяца назад

    thank you sir for your better techer thank you a lot sir

  • @ChandanG94805
    @ChandanG94805 2 месяца назад +7

    I did'nt Understand this really

  • @ayomideayodele4461
    @ayomideayodele4461 5 лет назад

    Best tutorial

  • @yivo2824
    @yivo2824 5 лет назад

    thank you!

  • @dheerajkafaltia8474
    @dheerajkafaltia8474 5 лет назад

    Very confusing, but watching till end made it clear

  • @kshitijakulkarni8292
    @kshitijakulkarni8292 5 лет назад

    This video is very helpful..Thank you so much sir.It is really easy to understand..

  • @abhinashjena216
    @abhinashjena216 Год назад +2

    We love you ❤😊, sir

  • @naklecha
    @naklecha 5 лет назад +8

    Ideal speed for 2x speed

  • @danat8590
    @danat8590 5 лет назад

    thank you so much

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

    For this to work keys should be in sorted order or not?

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

    @Abdul Bari - Sir How did you get 4(3,4) as 4 not 3 ? can you please explain

  • @user-nm3uy6yu1r
    @user-nm3uy6yu1r 4 года назад

    good job man

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

    Sir , I had a dought that what if the values of q1,q2 .....are not given 🤔🤔🤔🤔🤔🤔🤔🤔

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

    Thank you, sir!

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

    Sir which ide you use for coding?

  • @AnitShrestha
    @AnitShrestha 5 лет назад

    Thank you.

  • @mpmukundh
    @mpmukundh 5 лет назад +3

    Sir please explain with algorithm

  • @user-zi3qt9kb2q
    @user-zi3qt9kb2q Месяц назад

    thankyou sir u explained well

  • @ronitkumar1838
    @ronitkumar1838 6 лет назад +1

    best explanation