SlideShare a Scribd company logo
1 of 35
Download to read offline
Optimal Binary Search Tree
Dr. P. Subathra
Prof/ IT
KAMARAJ College of Engg. & Tech
(AUTONOMOUS)
Madurai
Tamil Nadu
India
• If probabilities of searching for elements of a set are
known—e.g., from accumulated data about past
searches—it is natural to pose a question about an
optimal binary search tree for which the average
number of comparisons in a search is the smallest
possible.
• we limit our discussion to minimizing the average
number of comparisons in a successful search.
• The method can be extended to include unsuccessful
searches as well.
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
2
• The total number of binary search trees with n
keys is equal to the nth Catalan number
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
3
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
4
OBST CREATION
(j-i)=0
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0
1
2
3
4
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
5
OBST CREATION
No. of Nodes = 0
(j-i)=0
(0-0) = 0 = C[0,0]
(1-1) = 0 = C[1,1]
(2-2) = 0 = C[2,2]
(3-3) = 0 = C[3,3]
(4-4) = 0 = C[4,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0
1 0
2 0
3 0
4 0
6
OBST CREATION
No. of Nodes = 1
(j-i)=1
(1-0) = 1 = C[0,1]
(2-1) = 1 = C[1,2]
(3-2) = 1 = C[2,3]
(4-3) = 1 = C[3,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0
1 0
2 0
3 0
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
7
OBST CREATION
No. of Nodes = 1
(j-i)=1
(1-0) = 1 = C[0,1] = 41
(2-1) = 1 = C[1,2]
(3-2) = 1 = C[2,3]
(4-3) = 1 = C[3,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0 41
1 0
2 0
3 0
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
8
OBST CREATION
No. of Nodes = 1
(j-i)=1
(1-0) = 1 = C[0,1] = 41
(2-1) = 1 = C[1,2] = 22
(3-2) = 1 = C[2,3]
(4-3) = 1 = C[3,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0 41
1 0 22
2 0
3 0
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
9
OBST CREATION
No. of Nodes = 1
(j-i)=1
(1-0) = 1 = C[0,1] = 41
(2-1) = 1 = C[1,2] = 22
(3-2) = 1 = C[2,3] = 63
(4-3) = 1 = C[3,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0 41
1 0 22
2 0 63
3 0
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
10
OBST CREATION
No. of Nodes = 1
(j-i)=1
(1-0) = 1 = C[0,1] = 41
(2-1) = 1 = C[1,2] = 22
(3-2) = 1 = C[2,3] = 63
(4-3) = 1 = C[3,4] = 34
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0 41
1 0 22
2 0 63
3 0 34
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
11
OBST CREATION
No. of Nodes = 2
(j-i)=2
(2-0) = 2 = C[0,2]
(3-1) = 2 = C[1,3]
(4-2) = 2 = C[2,4]
Item 1 2 3 4
Key 10 20 30 40
Freq 4 2 6 3
i j 0 1 2 3 4
0 0 41
1 0 22
2 0 63
3 0 34
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
12
OBST CREATION
No. of Nodes = 2 : (1&2)
C[0,2] : i = 0; j =2; k = 1, 2;
k =1
C[0, 1-1] + C[1, 2]
= min k=2 + (W1+W2)
C[0, 2-1] + C[2, 2]
= min k= 1 (0+2)
k= 2 (0+6)
= 2 + 6 = 81
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81
1 0 22
2 0 63
3 0 34
4 0
+ (4+2)
13
OBST CREATION
No. of Nodes = 2 : (2&3)
C[1,3] : i = 1; j =3; k = 2, 3;
k =2
C[1, 2-1] + C[2, 3]
= min k=3 + (W2+W3)
C[1, 3-1] + C[3, 3]
= min k= 2 (0+6)
k= 3 (2+0)
= 2 + 8 = 103
Item 1 2 3 4
Key 10 20 30 40
Freq
(W)
4 2 6 3
i j 0 1 2 3 4
0 0 41 81
1 0 22 103
2 0 63
3 0 34
4 0
+ (2+6)
14
OBST CREATION
No. of Nodes = 2 : (3&4)
C[2,4] : i = 2; j =4; k = 3, 4;
k =3
C[2, 3-1] + C[3, 4]
= min k=4 + (W2+W3)
C[2, 4-1] + C[4, 4]
= min k= 3 (0+3)
k= 4 (6+0)
= 3 + 9 = 123
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81
1 0 22 103
2 0 63 123
3 0 34
4 0
+ (6+3)
15
OBST CREATION
No. of Nodes = 3 :
(j-i) = 3
(3-0) = 3 = C[0,3]
(4-1) = 3 = C[1,4]
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81
1 0 22 103
2 0 63 123
3 0 34
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
16
OBST CREATION
No. of Nodes = 3 : (1,2&3)
C[0,3] : i = 0; j =3; k = 1,2,3;
k =1
C[0, 1-1] + C[1, 3]
= min k=2
C[0, 2-1] + C[2, 3]
k=3 + (W1+W2+W3)
C[0, 3-1] + C[3, 3]
= min k= 1 (0+10)
k= 2 (4+6)
k= 3 (8+0)
= 8 + 12 = 203
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203
1 0 22 103
2 0 63 123
3 0 34
4 0
+ (4+2+6)
17
OBST CREATION
No. of Nodes = 3 : (2,3 & 4)
C[1,4] : i = 1; j =4; k = 2,3,4;
k =2
C[1, 2-1] + C[2, 4]
= min k=3
C[1, 3-1] + C[3, 4]
k=4 + (W2+W3+W4)
C[1, 4-1] + C[4, 4]
= min k= 2 (0+12)
k= 3 (2+3)
k= 4 (10+0)
= 5 + 11 = 163
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203
1 0 22 103 163
2 0 63 123
3 0 34
4 0
+ (2+6+3)
18
OBST CREATION
No. of Nodes = 4 :
(j-i) = 4
(4-0) = 4 = C[0,4]
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203
1 0 22 103 163
2 0 63 123
3 0 34
4 0
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
19
OBST CREATION
No. of Nodes = 4 : (1,2,3 & 4)
C[0,4] : i = 0; j =4; k = 1,2,3,4;
k=1
C[0, 1-1] + C[1, 4]
k =2
C[0, 2-1] + C[2, 4]
= min k=3
C[0, 3-1] + C[3, 4]
k=4 + (W1+W2+W3+W4)
C[0, 4-1] + C[4, 4]
= min k=1 (0+16)
k= 2 (4+12)
k= 3 (8+3)
k= 4 (20+0)
= 11 + 15 = 263
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
+ (4+2+6+3)
20
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
3
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
21
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
3
r(left, root-1) r(root, right)
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
22
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
r(left, root-1) r(root, right)
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
23
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
24
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(left, root-1) r(root, right)
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
25
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
26
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
27
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
28
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
29
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
30
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
r(1,1) r(2,2)
r(3,3) r(4,4)
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
31
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
r(0, 4)
r(0,2) r(3,4)
3
1 4
r(0,0) r(1,2)
r(left, root-1) r(root, right)
2
r(1,1) r(2,2)
r(3,3) r(4,4)
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
32
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
3
1 4
2
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
33
OBST CREATION
Item 1 2 3 4
Key 10 20 30 40
Freq (W) 4 2 6 3
i j 0 1 2 3 4
0 0 41 81 203 263
1 0 22 103 163
2 0 63 123
3 0 34
4 0
3
1 4
2
Dr. P. Subathra, KAMARAJ College of Engg &
Tech (AUTONOMOUS), Madurai,
Tamil Nadu, India
34
END…!!!

More Related Content

What's hot

data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back trackingAbinaya B
 
Master method
Master method Master method
Master method Rajendran
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAsst.prof M.Gokilavani
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplicationKumar
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithmsRajendran
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IMohamed Loey
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.Tariq Khan
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplicationKiran K
 

What's hot (20)

data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
Master method
Master method Master method
Master method
 
Time andspacecomplexity
Time andspacecomplexityTime andspacecomplexity
Time andspacecomplexity
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Stressen's matrix multiplication
Stressen's matrix multiplicationStressen's matrix multiplication
Stressen's matrix multiplication
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
 
Matrix chain multiplication
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
 
Analysis of algorithm
Analysis of algorithmAnalysis of algorithm
Analysis of algorithm
 
Binary search
Binary searchBinary search
Binary search
 

Similar to Optimal binary search tree dynamic programming

Measures of different reliability parameters for a complex redundant system u...
Measures of different reliability parameters for a complex redundant system u...Measures of different reliability parameters for a complex redundant system u...
Measures of different reliability parameters for a complex redundant system u...Alexander Decker
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
International journal of engineering issues vol 2015 - no 1 - paper4
International journal of engineering issues   vol 2015 - no 1 - paper4International journal of engineering issues   vol 2015 - no 1 - paper4
International journal of engineering issues vol 2015 - no 1 - paper4sophiabelthome
 
rbs - presentation about applications of machine learning.
rbs - presentation about applications of machine learning.rbs - presentation about applications of machine learning.
rbs - presentation about applications of machine learning.ChellamuthuMech
 
電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析Simen Li
 
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine TransformRadix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine TransformIJERA Editor
 
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIR
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIRMATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIR
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIREditor IJMTER
 
Optimal tuning proportional integral derivative controller on direct current ...
Optimal tuning proportional integral derivative controller on direct current ...Optimal tuning proportional integral derivative controller on direct current ...
Optimal tuning proportional integral derivative controller on direct current ...IJECEIAES
 
Radix-3 Algorithm for Realization of Discrete Fourier Transform
Radix-3 Algorithm for Realization of Discrete Fourier TransformRadix-3 Algorithm for Realization of Discrete Fourier Transform
Radix-3 Algorithm for Realization of Discrete Fourier TransformIJERA Editor
 
International journal of applied sciences and innovation vol 2015 - no 1 - ...
International journal of applied sciences and innovation   vol 2015 - no 1 - ...International journal of applied sciences and innovation   vol 2015 - no 1 - ...
International journal of applied sciences and innovation vol 2015 - no 1 - ...sophiabelthome
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick ReferenceMark Niemann-Ross
 
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approach
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial ApproachPREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approach
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approachahmet furkan emrehan
 
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...คณาธิป ยมณีย์
 

Similar to Optimal binary search tree dynamic programming (17)

Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)Knapsack dynamic programming formula top down (1)
Knapsack dynamic programming formula top down (1)
 
Measures of different reliability parameters for a complex redundant system u...
Measures of different reliability parameters for a complex redundant system u...Measures of different reliability parameters for a complex redundant system u...
Measures of different reliability parameters for a complex redundant system u...
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Slides ads ia
Slides ads iaSlides ads ia
Slides ads ia
 
IA-advanced-R
IA-advanced-RIA-advanced-R
IA-advanced-R
 
International journal of engineering issues vol 2015 - no 1 - paper4
International journal of engineering issues   vol 2015 - no 1 - paper4International journal of engineering issues   vol 2015 - no 1 - paper4
International journal of engineering issues vol 2015 - no 1 - paper4
 
rbs - presentation about applications of machine learning.
rbs - presentation about applications of machine learning.rbs - presentation about applications of machine learning.
rbs - presentation about applications of machine learning.
 
電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析
 
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine TransformRadix-3 Algorithm for Realization of Type-II Discrete Sine Transform
Radix-3 Algorithm for Realization of Type-II Discrete Sine Transform
 
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIR
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIRMATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIR
MATHEMATICAL MODELING OF COMPLEX REDUNDANT SYSTEM UNDER HEAD-OF-LINE REPAIR
 
Optimal tuning proportional integral derivative controller on direct current ...
Optimal tuning proportional integral derivative controller on direct current ...Optimal tuning proportional integral derivative controller on direct current ...
Optimal tuning proportional integral derivative controller on direct current ...
 
Radix-3 Algorithm for Realization of Discrete Fourier Transform
Radix-3 Algorithm for Realization of Discrete Fourier TransformRadix-3 Algorithm for Realization of Discrete Fourier Transform
Radix-3 Algorithm for Realization of Discrete Fourier Transform
 
VTU Affiliated Colleges
VTU Affiliated CollegesVTU Affiliated Colleges
VTU Affiliated Colleges
 
International journal of applied sciences and innovation vol 2015 - no 1 - ...
International journal of applied sciences and innovation   vol 2015 - no 1 - ...International journal of applied sciences and innovation   vol 2015 - no 1 - ...
International journal of applied sciences and innovation vol 2015 - no 1 - ...
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick Reference
 
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approach
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial ApproachPREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approach
PREDICTION MODELS BASED ON MAX-STEMS Episode Two: Combinatorial Approach
 
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
 

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai

More from P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai (20)

TestFile
TestFileTestFile
TestFile
 
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
3.1 Trees ( Introduction, Binary Trees & Binary Search Trees)
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
 
1. 6 doubly linked list
1. 6 doubly linked list1. 6 doubly linked list
1. 6 doubly linked list
 
1. 5 Circular singly linked list
1. 5 Circular singly linked list1. 5 Circular singly linked list
1. 5 Circular singly linked list
 
1. 4 Singly linked list deletion
1. 4 Singly linked list deletion1. 4 Singly linked list deletion
1. 4 Singly linked list deletion
 
1. 3 singly linked list insertion 2
1. 3 singly linked list   insertion 21. 3 singly linked list   insertion 2
1. 3 singly linked list insertion 2
 
1. 2 Singly Linked List
1. 2 Singly Linked List1. 2 Singly Linked List
1. 2 Singly Linked List
 
1. C Basics for Data Structures Bridge Course
1. C Basics for Data Structures   Bridge Course1. C Basics for Data Structures   Bridge Course
1. C Basics for Data Structures Bridge Course
 
Approximation Algorithms TSP
Approximation Algorithms   TSPApproximation Algorithms   TSP
Approximation Algorithms TSP
 
The stable marriage problem iterative improvement method
The stable marriage problem iterative improvement methodThe stable marriage problem iterative improvement method
The stable marriage problem iterative improvement method
 
Maximum matching in bipartite graphs iterative improvement method
Maximum matching in bipartite graphs   iterative improvement methodMaximum matching in bipartite graphs   iterative improvement method
Maximum matching in bipartite graphs iterative improvement method
 
Knapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom upKnapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom up
 
Huffman tree coding greedy approach
Huffman tree coding  greedy approachHuffman tree coding  greedy approach
Huffman tree coding greedy approach
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Simplex method
Simplex methodSimplex method
Simplex method
 
Multiplication of integers & strassens matrix multiplication subi notes
Multiplication of integers & strassens matrix multiplication   subi notesMultiplication of integers & strassens matrix multiplication   subi notes
Multiplication of integers & strassens matrix multiplication subi notes
 
Multiplication of large integers problem subi notes
Multiplication of large integers  problem  subi notesMultiplication of large integers  problem  subi notes
Multiplication of large integers problem subi notes
 
Huffman tree coding
Huffman tree codingHuffman tree coding
Huffman tree coding
 

Recently uploaded

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
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
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
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 

Recently uploaded (20)

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
 
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
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
🔝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...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
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
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
★ 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
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 

Optimal binary search tree dynamic programming

  • 1. Optimal Binary Search Tree Dr. P. Subathra Prof/ IT KAMARAJ College of Engg. & Tech (AUTONOMOUS) Madurai Tamil Nadu India
  • 2. • If probabilities of searching for elements of a set are known—e.g., from accumulated data about past searches—it is natural to pose a question about an optimal binary search tree for which the average number of comparisons in a search is the smallest possible. • we limit our discussion to minimizing the average number of comparisons in a successful search. • The method can be extended to include unsuccessful searches as well. Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 2
  • 3. • The total number of binary search trees with n keys is equal to the nth Catalan number Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 3
  • 4. Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 4
  • 5. OBST CREATION (j-i)=0 Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 1 2 3 4 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 5
  • 6. OBST CREATION No. of Nodes = 0 (j-i)=0 (0-0) = 0 = C[0,0] (1-1) = 0 = C[1,1] (2-2) = 0 = C[2,2] (3-3) = 0 = C[3,3] (4-4) = 0 = C[4,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 1 0 2 0 3 0 4 0 6
  • 7. OBST CREATION No. of Nodes = 1 (j-i)=1 (1-0) = 1 = C[0,1] (2-1) = 1 = C[1,2] (3-2) = 1 = C[2,3] (4-3) = 1 = C[3,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 1 0 2 0 3 0 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 7
  • 8. OBST CREATION No. of Nodes = 1 (j-i)=1 (1-0) = 1 = C[0,1] = 41 (2-1) = 1 = C[1,2] (3-2) = 1 = C[2,3] (4-3) = 1 = C[3,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 41 1 0 2 0 3 0 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 8
  • 9. OBST CREATION No. of Nodes = 1 (j-i)=1 (1-0) = 1 = C[0,1] = 41 (2-1) = 1 = C[1,2] = 22 (3-2) = 1 = C[2,3] (4-3) = 1 = C[3,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 41 1 0 22 2 0 3 0 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 9
  • 10. OBST CREATION No. of Nodes = 1 (j-i)=1 (1-0) = 1 = C[0,1] = 41 (2-1) = 1 = C[1,2] = 22 (3-2) = 1 = C[2,3] = 63 (4-3) = 1 = C[3,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 41 1 0 22 2 0 63 3 0 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 10
  • 11. OBST CREATION No. of Nodes = 1 (j-i)=1 (1-0) = 1 = C[0,1] = 41 (2-1) = 1 = C[1,2] = 22 (3-2) = 1 = C[2,3] = 63 (4-3) = 1 = C[3,4] = 34 Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 41 1 0 22 2 0 63 3 0 34 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 11
  • 12. OBST CREATION No. of Nodes = 2 (j-i)=2 (2-0) = 2 = C[0,2] (3-1) = 2 = C[1,3] (4-2) = 2 = C[2,4] Item 1 2 3 4 Key 10 20 30 40 Freq 4 2 6 3 i j 0 1 2 3 4 0 0 41 1 0 22 2 0 63 3 0 34 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 12
  • 13. OBST CREATION No. of Nodes = 2 : (1&2) C[0,2] : i = 0; j =2; k = 1, 2; k =1 C[0, 1-1] + C[1, 2] = min k=2 + (W1+W2) C[0, 2-1] + C[2, 2] = min k= 1 (0+2) k= 2 (0+6) = 2 + 6 = 81 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 1 0 22 2 0 63 3 0 34 4 0 + (4+2) 13
  • 14. OBST CREATION No. of Nodes = 2 : (2&3) C[1,3] : i = 1; j =3; k = 2, 3; k =2 C[1, 2-1] + C[2, 3] = min k=3 + (W2+W3) C[1, 3-1] + C[3, 3] = min k= 2 (0+6) k= 3 (2+0) = 2 + 8 = 103 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 1 0 22 103 2 0 63 3 0 34 4 0 + (2+6) 14
  • 15. OBST CREATION No. of Nodes = 2 : (3&4) C[2,4] : i = 2; j =4; k = 3, 4; k =3 C[2, 3-1] + C[3, 4] = min k=4 + (W2+W3) C[2, 4-1] + C[4, 4] = min k= 3 (0+3) k= 4 (6+0) = 3 + 9 = 123 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 1 0 22 103 2 0 63 123 3 0 34 4 0 + (6+3) 15
  • 16. OBST CREATION No. of Nodes = 3 : (j-i) = 3 (3-0) = 3 = C[0,3] (4-1) = 3 = C[1,4] Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 1 0 22 103 2 0 63 123 3 0 34 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 16
  • 17. OBST CREATION No. of Nodes = 3 : (1,2&3) C[0,3] : i = 0; j =3; k = 1,2,3; k =1 C[0, 1-1] + C[1, 3] = min k=2 C[0, 2-1] + C[2, 3] k=3 + (W1+W2+W3) C[0, 3-1] + C[3, 3] = min k= 1 (0+10) k= 2 (4+6) k= 3 (8+0) = 8 + 12 = 203 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 1 0 22 103 2 0 63 123 3 0 34 4 0 + (4+2+6) 17
  • 18. OBST CREATION No. of Nodes = 3 : (2,3 & 4) C[1,4] : i = 1; j =4; k = 2,3,4; k =2 C[1, 2-1] + C[2, 4] = min k=3 C[1, 3-1] + C[3, 4] k=4 + (W2+W3+W4) C[1, 4-1] + C[4, 4] = min k= 2 (0+12) k= 3 (2+3) k= 4 (10+0) = 5 + 11 = 163 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 1 0 22 103 163 2 0 63 123 3 0 34 4 0 + (2+6+3) 18
  • 19. OBST CREATION No. of Nodes = 4 : (j-i) = 4 (4-0) = 4 = C[0,4] Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 1 0 22 103 163 2 0 63 123 3 0 34 4 0 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 19
  • 20. OBST CREATION No. of Nodes = 4 : (1,2,3 & 4) C[0,4] : i = 0; j =4; k = 1,2,3,4; k=1 C[0, 1-1] + C[1, 4] k =2 C[0, 2-1] + C[2, 4] = min k=3 C[0, 3-1] + C[3, 4] k=4 + (W1+W2+W3+W4) C[0, 4-1] + C[4, 4] = min k=1 (0+16) k= 2 (4+12) k= 3 (8+3) k= 4 (20+0) = 11 + 15 = 263 Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 + (4+2+6+3) 20
  • 21. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) 3 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 21
  • 22. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) 3 r(left, root-1) r(root, right) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 22
  • 23. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 r(left, root-1) r(root, right) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 23
  • 24. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 24
  • 25. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(left, root-1) r(root, right) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 25
  • 26. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 26
  • 27. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 27
  • 28. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 28
  • 29. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 29
  • 30. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 r(1,1) r(2,2) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 30
  • 31. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 r(1,1) r(2,2) r(3,3) r(4,4) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 31
  • 32. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 r(0, 4) r(0,2) r(3,4) 3 1 4 r(0,0) r(1,2) r(left, root-1) r(root, right) 2 r(1,1) r(2,2) r(3,3) r(4,4) Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 32
  • 33. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 3 1 4 2 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 33
  • 34. OBST CREATION Item 1 2 3 4 Key 10 20 30 40 Freq (W) 4 2 6 3 i j 0 1 2 3 4 0 0 41 81 203 263 1 0 22 103 163 2 0 63 123 3 0 34 4 0 3 1 4 2 Dr. P. Subathra, KAMARAJ College of Engg & Tech (AUTONOMOUS), Madurai, Tamil Nadu, India 34