Optimal Binary Search Trees with Example in Hindi #2 | Dynamic Programming

  Рет қаралды 103,522

Last moment tuitions

Last moment tuitions

Күн бұрын

Пікірлер: 141
@aalishanhunzai
@aalishanhunzai 11 ай бұрын
amazing video corrections: c(0,4) 19 with root 3 c(1,4) 11 with root 4 graph is: r(0,4) / 3 \ r(0,2) r(3,4) / 1 \ / 4 \ r(0,0) r(1,2) r(3,3) r(4,4) / \ r(1,1) r(2,2) result: 15 / \ 5 20 \ 3
@adultlucifergremory5435
@adultlucifergremory5435 8 ай бұрын
Bhai last me 10 hai 3 ki jagah
@SonuYadav-ub1zx
@SonuYadav-ub1zx 2 жыл бұрын
Cost (1,4 ) is 11 with root 4 & c(0,4) is 19 with root 3
@kumarabhinav1577
@kumarabhinav1577 Жыл бұрын
*Correction* C[1,4] is 11 and root is 4 C[0,4] is 19 and root is 3 //it's okay we're here to learn the concept.
@User-student-404
@User-student-404 Жыл бұрын
best comment in the comment section 👍👍
@aalishanhunzai
@aalishanhunzai 11 ай бұрын
iska phir jo vertexes bana rahe wo zyada arha ha
@thefuntech2810
@thefuntech2810 5 жыл бұрын
answer is wrong I filled all blocks C(1,4)=11 C(0,4)=19 And root is vertex 3
@manjeet_manu
@manjeet_manu 5 жыл бұрын
BUT ISKA TREE KAISE BANEGA
@thefuntech2810
@thefuntech2810 5 жыл бұрын
@@manjeet_manu wahi process follow karo
@mahiransh9894
@mahiransh9894 5 жыл бұрын
Bhai final answer bta de yrr... Kll paper hai...!!!
@thefuntech2810
@thefuntech2810 5 жыл бұрын
@@mahiransh9894 video poori dekhlo phir apne aap samaj mai aa jayega UP se ho kya AKTU University ?
@jaxim8520
@jaxim8520 4 жыл бұрын
C[0,4]= 14 Shi h C[0,4] ka answer
@devaganeshnair5883
@devaganeshnair5883 4 жыл бұрын
C[1,4]= 11 root 4 C[0,4]= 19 root 3 15 /\ 5. 20 \ 10
@rahulray7650
@rahulray7650 2 жыл бұрын
totally correct👌👌👌👌
@AnkitSingh-ye4xj
@AnkitSingh-ye4xj 2 жыл бұрын
crct 👍
@yogeshwarimarathe2277
@yogeshwarimarathe2277 2 жыл бұрын
How this 15 came as a root?
@jacobabineshjoseph2523
@jacobabineshjoseph2523 Жыл бұрын
@Mayur Chipade it's 2 bro if you see
@amanmourya6078
@amanmourya6078 Жыл бұрын
marked as best answer.
@ombothre2350
@ombothre2350 Жыл бұрын
Final Optimal BST :- 15 / \ 5 20 \ 10
@vishalghule4807
@vishalghule4807 Жыл бұрын
Tree in video is wrong?
@vishalghule4807
@vishalghule4807 Жыл бұрын
There he is starting from 5 then 20 , 15 ,10
@rajat129
@rajat129 Жыл бұрын
@@vishalghule4807 yes it is wrong in video , this is right answer
@vishalghule4807
@vishalghule4807 Жыл бұрын
@@rajat129 ok thanks 👍
@alinajaved2165
@alinajaved2165 10 ай бұрын
Final Optimal BST :- (0,4) 15 / \ r(0,0) 5 20 r(1,4) \ 10 how 5 came here becoz on r(0,0) it will stop
@hanzalamansuri9996
@hanzalamansuri9996 Ай бұрын
Formula : C[i][j] = C[i][k] + C[k+1][j] + W[i, j] With k = (1
@hanzalamansuri9996
@hanzalamansuri9996 Ай бұрын
For c[1][2] , k = 2... Because k is between i
@ankitgitm
@ankitgitm 4 жыл бұрын
The entry of (0, 4) will be 21 with root 3 Entry for (1,4) will be 11 with root 4 The final answer will be changed accordingly According to me, The final answer will be Root (15) / \ 5 20 \ 10
@ashakharkwal548
@ashakharkwal548 4 жыл бұрын
thankyouu
@deeepsss
@deeepsss 4 жыл бұрын
Bro, mujhe tho (0,4) ka 16 aaya hai, aur root 3. If possible kuch recall kar sakte ho kaisa aaya?
@shavnamsharma8340
@shavnamsharma8340 3 жыл бұрын
True
@sayalis_rangoli_art
@sayalis_rangoli_art 2 жыл бұрын
Right
@tdm2146
@tdm2146 2 жыл бұрын
💯% right...
@Morris64
@Morris64 2 жыл бұрын
General formula for calculating the minimum cost is: C[i,j] = min{c[i, k-1] + c[k,j]} + w(i,j)
@umesh6245
@umesh6245 2 жыл бұрын
what is K here?
@rajbelwal1634
@rajbelwal1634 Жыл бұрын
@@umesh6245 root vertex
@coderx7177
@coderx7177 2 жыл бұрын
Bhaiya bohot sahi video tha apne jo choti choti tricks batai isse remember krne k lie voh lajvab thi mene kai sare videos dekhe pr kuch nahi smjha apne har ek step achhese bataya hai bohot bohot dhanywaad ❤️.
@Lastmomenttuitions
@Lastmomenttuitions 2 жыл бұрын
Welcome
@aguyfromindia
@aguyfromindia 2 жыл бұрын
Thankyou sooo much you saved my whole life in just 30 mins :) . . . . . . . . . recommendation: go for only concept not for calculation.
@Lastmomenttuitions
@Lastmomenttuitions 2 жыл бұрын
Welcome
@prakashnavin6245
@prakashnavin6245 Жыл бұрын
thank you so much last moment tuition you guys are doing a really great job today is my final exam and after watching your video at 4: 35 am I got the concept very clearly. please keep uploading such informative video #engineers #btech
@neeketasaini3695
@neeketasaini3695 4 жыл бұрын
Sir the value of c(1,4)=11 with root Vertex 4.please let u clear this doubt.
@navjyoti3075
@navjyoti3075 3 жыл бұрын
Bhai apko pranam kitna acche seh apne samjhaya ❤️ mera abhi 4 sem m ei topic h smj nhi arha tha toh search kia aur baki smj a gya pura 😁😁 thnks bhai
@anupsingh9978
@anupsingh9978 2 жыл бұрын
Cost of [1,4] =11 because weight of w[1,4] =7 So 7 + 4 = 11 And 11 is answer not 4 ok students don't be confused.
@zilesingh6349
@zilesingh6349 Жыл бұрын
Sir aapse (1,4) mistake ho gye hai usme aapne weight ko add nahi kiya Vo 11 hona tha uske vajah se (0,4) b galat ho gya . But sir aapne bahut acha samjaya mera exact tree create huya hai thanku so much...
@shivamtiwari9040
@shivamtiwari9040 6 ай бұрын
The mistake you made in calculation of c(1,4) made me recheck all my calculations and understand the concept more clearly.
@mihirnaidu5211
@mihirnaidu5211 2 жыл бұрын
Kya hi samjhae aap bhaiya luv u upar wala aapko bohot khushiyaan de tysm !!!!
@Lastmomenttuitions
@Lastmomenttuitions 2 жыл бұрын
Thanks
@goonbanode7988
@goonbanode7988 6 ай бұрын
C[0,4] is 14 is correct because we have to select the least value only c[1,4] is 11
@codingmania8856
@codingmania8856 4 жыл бұрын
Tree and answer are wrong because C[1,4] is 11 and C[0,4] is 19. so the root will be 3.
@EnglsihCommByNawaz
@EnglsihCommByNawaz 2 жыл бұрын
Exactly
@sayantanbandyopadhyay7803
@sayantanbandyopadhyay7803 Жыл бұрын
exactly bro...
@chandamourya7101
@chandamourya7101 Жыл бұрын
Par root 3 .. 2 bar aaya hai tho kisa tree build Kara
@educationsingh2038
@educationsingh2038 Жыл бұрын
True
@Techie_jay03
@Techie_jay03 Жыл бұрын
Ha na bhai..main tension main agya tha😅😅
@sp8976
@sp8976 10 күн бұрын
GAJAB EXPLAINATION 🔥
@Error-zp3bn
@Error-zp3bn 5 жыл бұрын
Cost (1,4) mai w(1,4) ki value add nhi ki hai
@zohakhan1934
@zohakhan1934 5 ай бұрын
Was method rightly explained ? Should I consider it for my exam
@63yashshimpi79
@63yashshimpi79 Жыл бұрын
Q: Construct OBST for the given instances, If N=4, Set of Identifiers {a1, a2, a3, a4}= {do, if, int, while }, P(1:4)={p1,p2,p3,p4}={3,3,1,1} and Q(0:4)= {q0,q1,q2,q3,q4}={2,3,1,1,1} Construct a Optimal Binary Search Tree . 👆👆👆👆👆👆 koi muze iss question mese VERTEX , KEY ,& FREQUENCY batao plzzzzz
@harsshadshivsharan.6539
@harsshadshivsharan.6539 Жыл бұрын
To construct an optimal binary search tree (OBST) for the given instances, we can use the dynamic programming approach. Let's go through the steps to construct the OBST: Step 1: Initialize the tables and arrays. Create two-dimensional tables cost and root of size (N+2) x (N+1). Create an array P of size (N+1) to store the probabilities. Create an array Q of size (N+2) to store the cumulative probabilities. Step 2: Calculate cumulative probabilities. Initialize Q(0) = 0. For i = 1 to N+1: Q(i) = Q(i-1) + P(i-1). Step 3: Initialize the cost table. For i = 1 to N+1: cost(i, i-1) = Q(i) + Q(i-1). Step 4: Build the optimal binary search tree. For L = 1 to N: For i = 1 to N-L+1: j = i + L - 1 cost(i, j) = infinity For r = i to j: c = cost(i, r-1) + cost(r+1, j) + sum of P(i:j) + sum of Q(i:j+1) If c < cost(i, j): cost(i, j) = c root(i, j) = r Step 5: Print the optimal binary search tree. Call a recursive function printOBST(root, i, j): If i > j: Print "d" + (j+1) Else: Print "if" + (root(i, j)) + " (d" + (root(i, j)-1) + ", " + "d" + (root(i, j)+1) + ")" Recursively call printOBST(root, i, root(i, j)-1) Recursively call printOBST(root, root(i, j)+1, j) Now, let's apply these steps to the given instances: Step 1: Initialize the tables and arrays. N = 4 Set of Identifiers: {do, if, int, while } P(1:4) = {3, 3, 1, 1} Q(0:4) = {2, 3, 1, 1, 1} Step 2: Calculate cumulative probabilities. Q(0) = 0 Q(1) = Q(0) + P(0) = 0 + 3 = 3 Q(2) = Q(1) + P(1) = 3 + 3 = 6 Q(3) = Q(2) + P(2) = 6 + 1 = 7 Q(4) = Q(3) + P(3) = 7 + 1 = 8 Step 3: Initialize the cost table. cost(1, 0) = Q(1) + Q(0) = 3 + 2 = 5 cost(2, 1) = Q(2) + Q(1) = 6 + 3 = 9 cost(3, 2) = Q(3) + Q(2) = 7 + 6 = 13 cost(4, 3) = Q(4) + Q(3) = 8 + 7 = 15 Step 4: Build the optimal binary search tree. For L = 1: For i = 1: j = 1 + 1 - 1 = 1 cost(1, 1) = infinity For r = 1 to 1: c = cost(1, 1-1) + cost(1+1, 1) + P(1) + Q(1:2) If c < cost(1, 1): cost(1, 1) = c root(1, 1) = 1 For L = 2: For i = 1: j = 1 + 2 - 1 = 2 cost(1, 2) = infinity For r = 1 to 2: c = cost(1, 1-1) + cost(1+1, 2) + sum of P(1:2) + sum of Q(1:3) If c < cost(1, 2): cost(1, 2) = c root(1, 2) = 2 For i = 2: j = 2 + 2 - 1 = 3 cost(2, 3) = infinity For r = 2 to 3: c = cost(2, 2-1) + cost(2+1, 3) + P(2) + Q(2:4) If c < cost(2, 3): cost(2, 3) = c root(2, 3) = 3 For L = 3: For i = 1: j = 1 + 3 - 1 = 3 cost(1, 3) = infinity For r = 1 to 3: c = cost(1, 1-1) + cost(1+1, 3) + sum of P(1:3) + sum of Q(1:4) If c < cost(1, 3): cost(1, 3) = c root(1, 3) = 2 For i = 2: j = 2 + 3 - 1 = 4 cost(2, 4) = infinity For r = 2 to 4: c = cost(2, 2-1) + cost(2+1, 4) + sum of P(2:4) + sum of Q(2:5) If c < cost(2, 4): cost(2, 4) = c root(2, 4) = 3 For i = 3: j = 3 + 3 - 1 = 5 cost(3, 5) = infinity For r = 3 to 5: c = cost(3, 3-1) + cost(3+1, 5) + sum of P(3:4) + sum of Q(3:5) If c < cost(3, 5): cost(3, 5) = c root(3, 5) = 4 Step 5: Print the optimal binary search tree. Call printOBST(root, 1, 4): Print "if3 (d2, d4)" Call printOBST(root, 1, 2): Print "do (d1, d2)" Print "int (d3, d4)" Call printOBST(root, 4, 4): Print "while (d5)" The optimal binary search tree is as follows: Copy code if3 / \ do while int Note: The "d" + (index) represents a dummy node.
@ashwinikakade3418
@ashwinikakade3418 6 ай бұрын
1 number shikavle tumchyamul maze 6 marks fix zale sir....👍🙏
@rakshitmehra9199
@rakshitmehra9199 5 жыл бұрын
C(1,4)=11
@kunalbudhiraja7761
@kunalbudhiraja7761 3 жыл бұрын
Literally cramming of algorithm
@SalimShaikh-fx4kz
@SalimShaikh-fx4kz 2 жыл бұрын
impressed bhai,after watching too many videos ,this clearifies the concept
@Lastmomenttuitions
@Lastmomenttuitions 2 жыл бұрын
Thanks
@manjirikulkarni805
@manjirikulkarni805 5 жыл бұрын
c(1,4)=11
@shreechatane9215
@shreechatane9215 Жыл бұрын
Thank you bro very useful content ✌🏻
@anupsingh9978
@anupsingh9978 2 жыл бұрын
And cost of [0,4] will be 19
@spiritual487
@spiritual487 6 ай бұрын
[1,4] is 14
@krishi2760
@krishi2760 2 жыл бұрын
Excellent explanation but values are wrongly calculated
@sahilchoudharypublicvlogs4456
@sahilchoudharypublicvlogs4456 4 жыл бұрын
how you calculated (1,3) please tell
@saurabhkumarkardam8782
@saurabhkumarkardam8782 5 жыл бұрын
Why did u not fill the all block ?
@shahjee-iy4gu
@shahjee-iy4gu Жыл бұрын
You are genius
@unknownman1
@unknownman1 5 жыл бұрын
tum jio ek lakh saal :)
@meenakshirawat6213
@meenakshirawat6213 11 ай бұрын
[1,3]=4. is it right??? my answer is different
@devanshgupta2772
@devanshgupta2772 11 ай бұрын
answer is wrong I filled all blocks C(1,4)=11 C(0,4)=19 And root is vertex 3
@devanshgupta2772
@devanshgupta2772 11 ай бұрын
Final Optimal BST :- 15 / \ 5 20 \ 10
@satyammahajan2773
@satyammahajan2773 3 жыл бұрын
In C (1,3) it's coming 7 instead of 4 with root vertex 3
@deftme5440
@deftme5440 3 жыл бұрын
Don't include weight of 1 in the calculation of w(1,3), therefore weight will be 1+2 =3 , so calculation part will be , C(1,3)=c(1,2)+c(3,3)+3 C(1,3)= 1+0+3=4
@kushalbhatt6266
@kushalbhatt6266 11 ай бұрын
thanks bro
@djagadeshwar7983
@djagadeshwar7983 2 жыл бұрын
You not added w(1,4) in cost(1,4)
@awesomechintz7076
@awesomechintz7076 2 жыл бұрын
Bhai h tu mera😘
@studywarriors-i1h
@studywarriors-i1h 8 ай бұрын
besttttt ever
@amrutkajave6787
@amrutkajave6787 4 жыл бұрын
c(1,4) = 4 ❌
@amrutkajave6787
@amrutkajave6787 4 жыл бұрын
hence ans is wrong!
@yunusahmed5799
@yunusahmed5799 Жыл бұрын
(1, 4) = 11 with root 4 and (0,4)=19 with root 3
@suryakantasundaray932
@suryakantasundaray932 2 жыл бұрын
any doubt?? ask me
@CSEBivekKumarSahNirala
@CSEBivekKumarSahNirala 4 жыл бұрын
thank you sir
@anshagarwal5999
@anshagarwal5999 10 ай бұрын
waah kya ladka hai
@danish_gaming01
@danish_gaming01 2 жыл бұрын
Good 👍👍👍👍👍
@siddhantking7659
@siddhantking7659 Жыл бұрын
itne time me to 3 question solve hojayenge
@rockiggo
@rockiggo 2 жыл бұрын
Tqs sir
@amanchaurasiya3065
@amanchaurasiya3065 5 жыл бұрын
Thanks bhai
@sumitsharma5058
@sumitsharma5058 3 жыл бұрын
Dislike to missed the typical part of the video..
@aishwaryatiwari3618
@aishwaryatiwari3618 4 жыл бұрын
what have u done....its a blunder....optimal weight is 19 not 14....tree is fully wrong...check before uploading
@Zmayur143
@Zmayur143 2 жыл бұрын
Sir, can you please tell me what if the vertex is starting from 0 rather than 1? Means in your example vertex are 1,2,3,4 but what if they are 0,1,2,3? I'm very confused in this situation. I can't ignore the previous value because of that 0.
@mihirnaidu5211
@mihirnaidu5211 2 жыл бұрын
Then we will take min nd consider 0s all values in (0,1) nd soo on!!!
@poojapatil4584
@poojapatil4584 4 жыл бұрын
Aapne sare box fill q nhi kiye
@thefuntech2810
@thefuntech2810 5 жыл бұрын
Badiya video hai ;)
@69miXxX
@69miXxX Жыл бұрын
Explain dynamic programming approach and apply it to construct optimal binary search tree using Huffman coding for weights given below (2,3,5,7,9,13)
@amrit8445
@amrit8445 3 жыл бұрын
Half part kyu ni solve kiya apne
@suryakantasundaray932
@suryakantasundaray932 2 жыл бұрын
doubt?
@nikhilmatta6686
@nikhilmatta6686 Жыл бұрын
why we are not considering keys here 😅
@nikhilmatta6686
@nikhilmatta6686 Жыл бұрын
can anyone please explain
@g13arpitrajput76
@g13arpitrajput76 5 жыл бұрын
Notes khaan h sir ...koi link nhi h notes ka
@RaveenRajSingh
@RaveenRajSingh 4 жыл бұрын
Answer is wrong sir
@khedkarsonali1680
@khedkarsonali1680 4 жыл бұрын
answer is wrong...
@saurabhkumarkardam8782
@saurabhkumarkardam8782 5 жыл бұрын
Bhai apne ye neeche ke blocks kyon nhi fill kare
@sumitsharma5058
@sumitsharma5058 3 жыл бұрын
Coz there u got (0,0) vertices and it means value is nothing. Hope u understand
@OmkarBcw
@OmkarBcw Жыл бұрын
Bhai kaunsa answer sahi hai bata do kal exam hai 🥲
@OmkarBcw
@OmkarBcw Жыл бұрын
answer . 15 / \ 5. 20 \ 10
@swapnilpatel9831
@swapnilpatel9831 Жыл бұрын
Wrong answer brooh!
@djagadeshwar7983
@djagadeshwar7983 2 жыл бұрын
It's wrong solution
@racingarena04
@racingarena04 10 ай бұрын
khud confuse h
@VARINDERSINGH-zn8mp
@VARINDERSINGH-zn8mp Жыл бұрын
not a proper explanation does not tell how to fill block c[1,3] and c[2,4] , because of that man i waste my 3 hour ,dislike
@prajwalmehare_
@prajwalmehare_ 6 ай бұрын
barabar nahii samjta bhaii , thoda explanation , writing ka tarika improve karo 😶😒😑😪
@Your_father78678
@Your_father78678 Жыл бұрын
Isko kuch ata nahi hai buus kuch bhi samjha raha hai
@Your_father78678
@Your_father78678 Жыл бұрын
Are acche se samjha phela khud Sikh ke aa
@mfaraday4044
@mfaraday4044 4 жыл бұрын
Thank you bhau
@bhushanvashist7556
@bhushanvashist7556 3 жыл бұрын
Thanks 👍
@Lastmomenttuitions
@Lastmomenttuitions 3 жыл бұрын
Welcome
@shishpal512
@shishpal512 3 жыл бұрын
thanks bhai
@Lastmomenttuitions
@Lastmomenttuitions 3 жыл бұрын
Welcome
Optimal Binary Search Trees with Example in Hindi  #1 | Dynamic Programming
13:29
4.5 0/1 Knapsack - Two Methods - Dynamic Programming
28:24
Abdul Bari
Рет қаралды 2,9 МЛН
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 88 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,5 МЛН
3.10 Optimal binary search tree with example
22:44
OU Education
Рет қаралды 44 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 442 М.
Optimal Storage on Tapes in Hindi - Greedy Method | DAA Lectures
7:34
Last moment tuitions
Рет қаралды 35 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
N Queen Problem using Backtracking with Example in Hindi
8:28
Last moment tuitions
Рет қаралды 204 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 88 МЛН