SlideShare a Scribd company logo
1 of 14
Download to read offline
OPTIMAL BINARY
SEARCH TREE
1KAVYA P , Asst. prof. , MIT Thandavapura
BINARY SEARCH TREE
2KAVYA P , Asst. prof. , MIT Thandavapura
OPTIMAL BINARY SEARCH TREE
Key A B C D
Probability 0.1 0.2 0.4 0.3
C
B
A
D
B
A
D
C
COST = 2.9 COST = 2.1
3KAVYA P , Asst. prof. , MIT Thandavapura
Construction of Optimal Binary
Search tree
4KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1
2 0 0.2
3 0 0.4
4 0 0.3
5 0
0 1 2 3 4
1 1
2 2
3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C[1,0] = 0
C[2,1] = 0
C[3,2] = 0
C[4, 3] = 0
C[5, 4] = 0
C[1,1] =0.1
C[2,2] = 0.2
C[3,3] = 0.4
C[4,4] = 0.3
R[1,1] = 1
R[2,2] =2
R[3,3] = 3
R[4,4] = 4
C[ i , i-1 ] = 0 C[ i , i ] = p[i] R[ i , i ] = i
5KAVYA P , Asst. prof. , MIT Thandavapura
 C [ i , j ] = min i <= k <= j{C [ i , k-1] + C [k+1 , j ] } + 𝑃𝑠
𝑗
𝑠=𝑖
6KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4
2 0 0.2
3 0 0.4
4 0 0.5
5 0
0 1 2 3 4
1 1 2
2 2
3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.5
MainTable C RootTable R
C[1, 2] = min { C [ 1, 0 ] + C [ 2, 2] , C[1,1] + C[3,2] } + P1 + P2
= min { 0 + 0.2 , 0.1 + 0 } + 0.1 + 0.2
= min { 0.2 , 0.1 } + 0.3
= 0.1 + 0.3
= 0.4 (root = 2)
K = 1 K = 2
7KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4
2 0 0.2 0.8
3 0 0.4
4 0 0.5
5 0
0 1 2 3 4
1 1 2
2 2 3
3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C [ 2, 3] = min { C [ 2, 1 ] + C [ 3 , 3] , C[2,2] + C [ 4 , 3] } + P2 + P3
= min { 0 + 0.4 , 0.2 + 0 } + 0.2 + 0.4
= min {0.4 , 0.2 } +0.6
= 0.2 + 0.6
= 0.8 ( root = 3)
K = 2 K = 3
8KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4
2 0 0.2 0.8
3 0 0.4 1.0
4 0 0.5
5 0
0 1 2 3 4
1 1 2
2 2 3
3 3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C [3, 4] = min { C[ 3, 2] + C[4, 4] , C[3, 3] + C[5,4] } +P3+P4
= min { 0 + 0.3 , 0.4 + 0 } + 0.4 + 0.3
= min { 0.3, 0.4} +0.7
= 0.3+ 0.9
= 1.0 (root = 3)
K = 3 K = 4
9KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4 1.1
2 0 0.2 0.8
3 0 0.4 1.0
4 0 0.5
5 0
0 1 2 3 4
1 1 2 3
2 2 3
3 3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C [ 1, 3 ] = min { C[1,0]+C[2,3] , C[1, 1] + C[3, 3] , C[1, 2] +C[4, 3] } +
P1+ P2 +P3
= min { 0 + 0.8 , 0.1 +0.4, 0.4 + 0} + 0.1 + 0.2 +0.4
= min {0.8 , 0.5 , 0.4 } + 0.7
= 0.4 + 0.7
= 1.1 ( root = 3)
K = 1 K = 2 K = 3
10KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4 1.1
2 0 0.2 0.8 1.4
3 0 0.4 1.0
4 0 0.5
5 0
0 1 2 3 4
1 1 2 3
2 2 3 3
3 3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C[2, 4] = min { C[2,1]+C[3,4] , C[2, 2] + C[4, 4] , C[2, 3] +C[5, 4] } +
P2+ P3 +P4
= min { 0 + 1.0 , 0.2 +0.3, 0.8 + 0} + 0.2 + 0.4 +0.3
= min {1.0 , 0.5 , 0.8 } + 0.9
= 0.5 + 0.93
= 1.4 ( root = 3)
K = 2 K = 3 K = 4
11KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 0 0.1 0.4 1.1 1.7
2 0 0.2 0.8 1.4
3 0 0.4 1.0
4 0 0.5
5 0
0 1 2 3 4
1 1 2 3 3
2 2 3 3
3 3 3
4 4
5
Key A B C D
Probability 0.1 0.2 0.4 0.3
MainTable C RootTable R
C[1, 4] = min { C[1,0]+C[2,4] , C[1,1] + C[3,4] , C[1, 2] +C[4, 4] , C[1,3]+C[5,4] }
+ P1+ P2 +P3+P4
= min { 0 + 1.4 , 0.1 +1.0, 0.4+0.3 , 1.1+0} + 0.1 + 0.2 + 0.4 + 0.3
= min {1.4, 1.1, 0.7, 1.1} + 1.0
= 0.7 + 1.0
= 1.7 ( root = 3)
K = 1 K = 2 K = 3 K = 4
12KAVYA P , Asst. prof. , MIT Thandavapura
0 1 2 3 4
1 1 2 3 3
2 2 3 3
3 3 3
4 4
5
RootTable R
C
KEYVALUE 1 2 3 4
Key A B C D
K = 3
B
A
D
(1, 2) = 2
(1, 1) = 1
(4, 4) = 4
OPTIMAL BINARY SEARCH TREE
COST = 1.7
13KAVYA P , Asst. prof. , MIT Thandavapura
Algorithm Optimal BST
14KAVYA P , Asst. prof. , MIT Thandavapura

More Related Content

What's hot

Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemMadhu Bala
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programingrupali_2bonde
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common SubsequenceKrishma Parekh
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplicationKumar
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequenceKiran K
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problemJayesh Chauhan
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy methodhodcsencet
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 

What's hot (20)

Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
 
Backtracking
BacktrackingBacktracking
Backtracking
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequence
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
 
Knapsack Problem
Knapsack ProblemKnapsack Problem
Knapsack Problem
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
 
Time complexity
Time complexityTime complexity
Time complexity
 

Similar to Optimal Binary Search Tree Construction Algorithm

Kuliah 10 Vektor.pptx
Kuliah 10 Vektor.pptxKuliah 10 Vektor.pptx
Kuliah 10 Vektor.pptxZaenurRohman7
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationKiran K
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure treerantd
 
Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationJaneAlamAdnan
 
4.9 cpm network calculations
4.9 cpm network calculations4.9 cpm network calculations
4.9 cpm network calculationsVishal Tidake
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyKimikazu Kato
 
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker NotesDeveloper Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker NotesMax De Marzi
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Dr. Volkan OBAN
 

Similar to Optimal Binary Search Tree Construction Algorithm (10)

Kuliah 10 Vektor.pptx
Kuliah 10 Vektor.pptxKuliah 10 Vektor.pptx
Kuliah 10 Vektor.pptx
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
Longest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain MultiplicationLongest Common Subsequence & Matrix Chain Multiplication
Longest Common Subsequence & Matrix Chain Multiplication
 
4.9 cpm network calculations
4.9 cpm network calculations4.9 cpm network calculations
4.9 cpm network calculations
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
Developer Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker NotesDeveloper Intro Deck-PowerPoint - Download for Speaker Notes
Developer Intro Deck-PowerPoint - Download for Speaker Notes
 
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
Optimization and Mathematical Programming in R and ROI - R Optimization Infra...
 

Recently uploaded

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 

Recently uploaded (20)

Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 

Optimal Binary Search Tree Construction Algorithm

  • 1. OPTIMAL BINARY SEARCH TREE 1KAVYA P , Asst. prof. , MIT Thandavapura
  • 2. BINARY SEARCH TREE 2KAVYA P , Asst. prof. , MIT Thandavapura
  • 3. OPTIMAL BINARY SEARCH TREE Key A B C D Probability 0.1 0.2 0.4 0.3 C B A D B A D C COST = 2.9 COST = 2.1 3KAVYA P , Asst. prof. , MIT Thandavapura
  • 4. Construction of Optimal Binary Search tree 4KAVYA P , Asst. prof. , MIT Thandavapura
  • 5. 0 1 2 3 4 1 0 0.1 2 0 0.2 3 0 0.4 4 0 0.3 5 0 0 1 2 3 4 1 1 2 2 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C[1,0] = 0 C[2,1] = 0 C[3,2] = 0 C[4, 3] = 0 C[5, 4] = 0 C[1,1] =0.1 C[2,2] = 0.2 C[3,3] = 0.4 C[4,4] = 0.3 R[1,1] = 1 R[2,2] =2 R[3,3] = 3 R[4,4] = 4 C[ i , i-1 ] = 0 C[ i , i ] = p[i] R[ i , i ] = i 5KAVYA P , Asst. prof. , MIT Thandavapura
  • 6.  C [ i , j ] = min i <= k <= j{C [ i , k-1] + C [k+1 , j ] } + 𝑃𝑠 𝑗 𝑠=𝑖 6KAVYA P , Asst. prof. , MIT Thandavapura
  • 7. 0 1 2 3 4 1 0 0.1 0.4 2 0 0.2 3 0 0.4 4 0 0.5 5 0 0 1 2 3 4 1 1 2 2 2 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.5 MainTable C RootTable R C[1, 2] = min { C [ 1, 0 ] + C [ 2, 2] , C[1,1] + C[3,2] } + P1 + P2 = min { 0 + 0.2 , 0.1 + 0 } + 0.1 + 0.2 = min { 0.2 , 0.1 } + 0.3 = 0.1 + 0.3 = 0.4 (root = 2) K = 1 K = 2 7KAVYA P , Asst. prof. , MIT Thandavapura
  • 8. 0 1 2 3 4 1 0 0.1 0.4 2 0 0.2 0.8 3 0 0.4 4 0 0.5 5 0 0 1 2 3 4 1 1 2 2 2 3 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C [ 2, 3] = min { C [ 2, 1 ] + C [ 3 , 3] , C[2,2] + C [ 4 , 3] } + P2 + P3 = min { 0 + 0.4 , 0.2 + 0 } + 0.2 + 0.4 = min {0.4 , 0.2 } +0.6 = 0.2 + 0.6 = 0.8 ( root = 3) K = 2 K = 3 8KAVYA P , Asst. prof. , MIT Thandavapura
  • 9. 0 1 2 3 4 1 0 0.1 0.4 2 0 0.2 0.8 3 0 0.4 1.0 4 0 0.5 5 0 0 1 2 3 4 1 1 2 2 2 3 3 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C [3, 4] = min { C[ 3, 2] + C[4, 4] , C[3, 3] + C[5,4] } +P3+P4 = min { 0 + 0.3 , 0.4 + 0 } + 0.4 + 0.3 = min { 0.3, 0.4} +0.7 = 0.3+ 0.9 = 1.0 (root = 3) K = 3 K = 4 9KAVYA P , Asst. prof. , MIT Thandavapura
  • 10. 0 1 2 3 4 1 0 0.1 0.4 1.1 2 0 0.2 0.8 3 0 0.4 1.0 4 0 0.5 5 0 0 1 2 3 4 1 1 2 3 2 2 3 3 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C [ 1, 3 ] = min { C[1,0]+C[2,3] , C[1, 1] + C[3, 3] , C[1, 2] +C[4, 3] } + P1+ P2 +P3 = min { 0 + 0.8 , 0.1 +0.4, 0.4 + 0} + 0.1 + 0.2 +0.4 = min {0.8 , 0.5 , 0.4 } + 0.7 = 0.4 + 0.7 = 1.1 ( root = 3) K = 1 K = 2 K = 3 10KAVYA P , Asst. prof. , MIT Thandavapura
  • 11. 0 1 2 3 4 1 0 0.1 0.4 1.1 2 0 0.2 0.8 1.4 3 0 0.4 1.0 4 0 0.5 5 0 0 1 2 3 4 1 1 2 3 2 2 3 3 3 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C[2, 4] = min { C[2,1]+C[3,4] , C[2, 2] + C[4, 4] , C[2, 3] +C[5, 4] } + P2+ P3 +P4 = min { 0 + 1.0 , 0.2 +0.3, 0.8 + 0} + 0.2 + 0.4 +0.3 = min {1.0 , 0.5 , 0.8 } + 0.9 = 0.5 + 0.93 = 1.4 ( root = 3) K = 2 K = 3 K = 4 11KAVYA P , Asst. prof. , MIT Thandavapura
  • 12. 0 1 2 3 4 1 0 0.1 0.4 1.1 1.7 2 0 0.2 0.8 1.4 3 0 0.4 1.0 4 0 0.5 5 0 0 1 2 3 4 1 1 2 3 3 2 2 3 3 3 3 3 4 4 5 Key A B C D Probability 0.1 0.2 0.4 0.3 MainTable C RootTable R C[1, 4] = min { C[1,0]+C[2,4] , C[1,1] + C[3,4] , C[1, 2] +C[4, 4] , C[1,3]+C[5,4] } + P1+ P2 +P3+P4 = min { 0 + 1.4 , 0.1 +1.0, 0.4+0.3 , 1.1+0} + 0.1 + 0.2 + 0.4 + 0.3 = min {1.4, 1.1, 0.7, 1.1} + 1.0 = 0.7 + 1.0 = 1.7 ( root = 3) K = 1 K = 2 K = 3 K = 4 12KAVYA P , Asst. prof. , MIT Thandavapura
  • 13. 0 1 2 3 4 1 1 2 3 3 2 2 3 3 3 3 3 4 4 5 RootTable R C KEYVALUE 1 2 3 4 Key A B C D K = 3 B A D (1, 2) = 2 (1, 1) = 1 (4, 4) = 4 OPTIMAL BINARY SEARCH TREE COST = 1.7 13KAVYA P , Asst. prof. , MIT Thandavapura
  • 14. Algorithm Optimal BST 14KAVYA P , Asst. prof. , MIT Thandavapura