SlideShare a Scribd company logo
6
Most read
13
Most read
15
Most read
Design and Analysis of Algorithm(18CS42)
Module 4
Dynamic programming
Lecture Presentation
Divya K S
Dept. of CSE
OPTIMAL BINARY SEARCH TREE
• Basic definitions
• Concepts of Optimal Binary Search Tree
• Example Problem
• Assignment
BINARY SEARCH TREE
• In A Binary Search Tree, The Value Of All The Nodes In The Left Sub-tree Is Less Than The Value Of The
Root.
• Similarly, Value Of All The Nodes In The Right Sub-tree Is Greater Than Or Equal To The Value Of The
Root.
• This Rule Will Be Recursively Applied To All The Left And Right Sub-trees Of The Root.
EXAMPLE
KEYS 1, 2,3
BST 3BST 2
BST 4
BST 1
BST
5
DEPTH=0,HEGHT=1
DEPTH=1,HEIGHT=2
DEPTH=2 HEIGHT=3
HEIGHT*FREQUEN
1*1+2*2+2*6=17
Lecture optimal binary search tree
Lecture optimal binary search tree
Cost: 13
• Using dynamic programming find the optimal binary search tree for
the given data.
Keys 10 12 16 21
Frequency 4 2 6 3
0 1 2 3 4
1 0 4
2 0 2
3 0 6
4 0 3
5 0
1 2 3 4
Keys 10 12 16 21
Frequency 4 2 6 3
Solution: Solution matrix
Formula:
0 1 2 3 4
1 0 4 8(1)
2 0 2 10(3
)
3 0 6
4 0 3
5 0
C[1,2]=
K=1
C[1,0]+C[2,2]=0+2=2---------
ROOT(1)
K=2
C[1,1]+C[3,2]=4+0=4
+ 6===8
C[2,3]=
I=2
J=3
K=2
C[2,1]+C[3,3]=0+6=6
K=3
C[2,2]+C[4,3]=2+0=2
+8===10
0 1 2 3 4
1 0 4 8(1) 20(3
)
26(3
)
2 0 2 10(3
)
16(3
)
3 0 6 12(3
)
4 0 3
5 0
C[3,4]
k=3
C[3,2]+C[4,4]=0+3=3
i=3,j=4 k=4
C[3,3]+C[5,4]=6+0=6
Frequency=9
=====12ROOT(3)
Minimum cost =2
16
10 21
12 Optimal Binary search
1*6=6
2*4+2*3=14
3*2=6
ALGORITHM OPTIMAL BINARY SEARCH TREE
ASSIGNMENT

More Related Content

What's hot (20)

PPTX
Binary search
AparnaKumari31
 
PPT
Lec 17 heap data structure
Sajid Marwat
 
PPT
Divide and conquer
Dr Shashikant Athawale
 
PPT
Binary Search
kunj desai
 
PPTX
Breadth First Search & Depth First Search
Kevin Jadiya
 
PPT
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
PPTX
heap Sort Algorithm
Lemia Algmri
 
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
PPT
Binary search tree(bst)
Hossain Md Shakhawat
 
PPTX
Graph coloring using backtracking
shashidharPapishetty
 
PPTX
Strassen's matrix multiplication
Megha V
 
PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PPTX
Backtracking
subhradeep mitra
 
PPTX
DFS and BFS
satya parsana
 
PPTX
Sorting Algorithms
Pranay Neema
 
PPTX
Bfs and Dfs
Masud Parvaze
 
PDF
linear search and binary search
Zia Ush Shamszaman
 
PDF
Time and Space Complexity
Ashutosh Satapathy
 
PPTX
Merge Sort
Nikhil Sonkamble
 
PPT
1.1 binary tree
Krish_ver2
 
Binary search
AparnaKumari31
 
Lec 17 heap data structure
Sajid Marwat
 
Divide and conquer
Dr Shashikant Athawale
 
Binary Search
kunj desai
 
Breadth First Search & Depth First Search
Kevin Jadiya
 
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
heap Sort Algorithm
Lemia Algmri
 
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Binary search tree(bst)
Hossain Md Shakhawat
 
Graph coloring using backtracking
shashidharPapishetty
 
Strassen's matrix multiplication
Megha V
 
Priority Queue in Data Structure
Meghaj Mallick
 
Backtracking
subhradeep mitra
 
DFS and BFS
satya parsana
 
Sorting Algorithms
Pranay Neema
 
Bfs and Dfs
Masud Parvaze
 
linear search and binary search
Zia Ush Shamszaman
 
Time and Space Complexity
Ashutosh Satapathy
 
Merge Sort
Nikhil Sonkamble
 
1.1 binary tree
Krish_ver2
 

Similar to Lecture optimal binary search tree (20)

PPTX
Optimal Binary Search tree ppt seminar.pptx
ssusered44c8
 
PPTX
OPTIMAL BINARY SEARCH
Cool Guy
 
PDF
Grokking TechTalk #27: Optimal Binary Search Tree
Grokking VN
 
PPTX
gayathri23.pptx
GayathriP95
 
PPTX
8.binry search tree
Chandan Singh
 
PPTX
Lecture 9 data structures and algorithms
Aakash deep Singhal
 
PDF
BinarySearchTree-bddicken
Benjamin Dicken
 
PPTX
Data Structure Algorithm
nibiganesh
 
PPTX
Binary Search Tree in Data Structure
Meghaj Mallick
 
PPTX
Binary search tree definition operation.pptx
jeevananandk28
 
PPT
Binary search tree in data structures
chauhankapil
 
PPTX
BinarySearchTree in datastructures in detail
kichokuttu
 
PPT
Binary Search Tree
Zafar Ayub
 
PDF
binarysearchtreeindatastructures-200604055006 (1).pdf
ajajkhan16
 
PPTX
Binary Search Tree In Python.pptx
RohanThota3
 
PPTX
10.m way search tree
Chandan Singh
 
PPTX
data structures module III & IV.pptx
rani marri
 
PPTX
Binary Search Tree
INAM352782
 
PPTX
DAA PPT.pptx
INAM352782
 
PPTX
Linear and Binary search
Nisha Soms
 
Optimal Binary Search tree ppt seminar.pptx
ssusered44c8
 
OPTIMAL BINARY SEARCH
Cool Guy
 
Grokking TechTalk #27: Optimal Binary Search Tree
Grokking VN
 
gayathri23.pptx
GayathriP95
 
8.binry search tree
Chandan Singh
 
Lecture 9 data structures and algorithms
Aakash deep Singhal
 
BinarySearchTree-bddicken
Benjamin Dicken
 
Data Structure Algorithm
nibiganesh
 
Binary Search Tree in Data Structure
Meghaj Mallick
 
Binary search tree definition operation.pptx
jeevananandk28
 
Binary search tree in data structures
chauhankapil
 
BinarySearchTree in datastructures in detail
kichokuttu
 
Binary Search Tree
Zafar Ayub
 
binarysearchtreeindatastructures-200604055006 (1).pdf
ajajkhan16
 
Binary Search Tree In Python.pptx
RohanThota3
 
10.m way search tree
Chandan Singh
 
data structures module III & IV.pptx
rani marri
 
Binary Search Tree
INAM352782
 
DAA PPT.pptx
INAM352782
 
Linear and Binary search
Nisha Soms
 
Ad

Recently uploaded (20)

PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
PDF
smart lot access control system with eye
rasabzahra
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Design Thinking basics for Engineers.pdf
CMR University
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
Big Data and Data Science hype .pptx
SUNEEL37
 
smart lot access control system with eye
rasabzahra
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Thermal runway and thermal stability.pptx
godow93766
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Ad

Lecture optimal binary search tree

  • 1. Design and Analysis of Algorithm(18CS42) Module 4 Dynamic programming Lecture Presentation Divya K S Dept. of CSE
  • 2. OPTIMAL BINARY SEARCH TREE • Basic definitions • Concepts of Optimal Binary Search Tree • Example Problem • Assignment
  • 3. BINARY SEARCH TREE • In A Binary Search Tree, The Value Of All The Nodes In The Left Sub-tree Is Less Than The Value Of The Root. • Similarly, Value Of All The Nodes In The Right Sub-tree Is Greater Than Or Equal To The Value Of The Root. • This Rule Will Be Recursively Applied To All The Left And Right Sub-trees Of The Root.
  • 6. BST 3BST 2 BST 4 BST 1 BST 5
  • 12. • Using dynamic programming find the optimal binary search tree for the given data. Keys 10 12 16 21 Frequency 4 2 6 3 0 1 2 3 4 1 0 4 2 0 2 3 0 6 4 0 3 5 0 1 2 3 4 Keys 10 12 16 21 Frequency 4 2 6 3 Solution: Solution matrix
  • 13. Formula: 0 1 2 3 4 1 0 4 8(1) 2 0 2 10(3 ) 3 0 6 4 0 3 5 0 C[1,2]= K=1 C[1,0]+C[2,2]=0+2=2--------- ROOT(1) K=2 C[1,1]+C[3,2]=4+0=4 + 6===8 C[2,3]= I=2 J=3 K=2 C[2,1]+C[3,3]=0+6=6 K=3 C[2,2]+C[4,3]=2+0=2 +8===10
  • 14. 0 1 2 3 4 1 0 4 8(1) 20(3 ) 26(3 ) 2 0 2 10(3 ) 16(3 ) 3 0 6 12(3 ) 4 0 3 5 0 C[3,4] k=3 C[3,2]+C[4,4]=0+3=3 i=3,j=4 k=4 C[3,3]+C[5,4]=6+0=6 Frequency=9 =====12ROOT(3) Minimum cost =2 16 10 21 12 Optimal Binary search 1*6=6 2*4+2*3=14 3*2=6