SlideShare a Scribd company logo
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…!!!
Ad

More Related Content

What's hot (20)

Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Merge Sort
Merge SortMerge Sort
Merge Sort
Nikhil Sonkamble
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadline
Arafat Hossan
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Ehtisham Ali
 
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
Mohamed Loey
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
padmeshagrekar
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
Abhishek Singh
 
Graph coloring using backtracking
Graph coloring using backtrackingGraph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
Pankaj Thakur
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
subhashchandra197
 
Marge Sort
Marge SortMarge Sort
Marge Sort
Ankit92Chitnavis
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
Subid Biswas
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
Quick Sort
Quick SortQuick Sort
Quick Sort
Shweta Sahu
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
Merge sort algorithm power point presentation
Merge sort algorithm power point presentationMerge sort algorithm power point presentation
Merge sort algorithm power point presentation
University of Science and Technology Chitttagong
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with exampleSingle source Shortest path algorithm with example
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
Job sequencing with deadline
Job sequencing with deadlineJob sequencing with deadline
Job sequencing with deadline
Arafat Hossan
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
Ehtisham Ali
 
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
Mohamed Loey
 
Knapsack problem using greedy approach
Knapsack problem using greedy approachKnapsack problem using greedy approach
Knapsack problem using greedy approach
padmeshagrekar
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
Abhishek Singh
 
Recurrence relation solutions
Recurrence relation solutionsRecurrence relation solutions
Recurrence relation solutions
subhashchandra197
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
Subid Biswas
 
03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf03 Linear Arrays Memory Representations .pdf
03 Linear Arrays Memory Representations .pdf
KkSingh64
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
Rishabh Soni
 
0/1 knapsack
0/1 knapsack0/1 knapsack
0/1 knapsack
Amin Omi
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with exampleSingle source Shortest path algorithm with example
Single source Shortest path algorithm with example
VINITACHAUHAN21
 

Similar to Optimal binary search tree dynamic programming (12)

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)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
 
Slides ads ia
Slides ads iaSlides ads ia
Slides ads ia
Arthur Charpentier
 
IA-advanced-R
IA-advanced-RIA-advanced-R
IA-advanced-R
Arthur Charpentier
 
電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析
Simen Li
 
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
Editor 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 Transform
IJERA Editor
 
VTU Affiliated Colleges
VTU Affiliated CollegesVTU Affiliated Colleges
VTU Affiliated Colleges
Mahesh Obannavar
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick Reference
Mark 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 Approach
ahmet furkan emrehan
 
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 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...
Alexander Decker
 
電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析電路學 - [第七章] 正弦激勵, 相量與穩態分析
電路學 - [第七章] 正弦激勵, 相量與穩態分析
Simen Li
 
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
Editor 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 Transform
IJERA Editor
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick Reference
Mark 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 Approach
ahmet furkan emrehan
 
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก  ตัวเลขไ...
แผนการจัดการเรียนรู้ที่ 1 เรื่อง การเขียนและการอ่านตัวเลขฮินดูอารบิก ตัวเลขไ...
คณาธิป ยมณีย์
 
Ad

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

TestFile
TestFileTestFile
TestFile
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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)
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
1. 6 doubly linked list
1. 6 doubly linked list1. 6 doubly linked list
1. 6 doubly linked list
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
1. 5 Circular singly linked list
1. 5 Circular singly linked list1. 5 Circular singly linked list
1. 5 Circular singly linked list
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
1. 4 Singly linked list deletion
1. 4 Singly linked list deletion1. 4 Singly linked list deletion
1. 4 Singly linked list deletion
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
1. 2 Singly Linked List
1. 2 Singly Linked List1. 2 Singly Linked List
1. 2 Singly Linked List
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Approximation Algorithms TSP
Approximation Algorithms   TSPApproximation Algorithms   TSP
Approximation Algorithms TSP
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Knapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom upKnapsack dynamic programming formula bottom up
Knapsack dynamic programming formula bottom up
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Huffman tree coding greedy approach
Huffman tree coding  greedy approachHuffman tree coding  greedy approach
Huffman tree coding greedy approach
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Simplex method
Simplex methodSimplex method
Simplex method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Simplex method
Simplex methodSimplex method
Simplex method
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
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
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Huffman tree coding
Huffman tree codingHuffman tree coding
Huffman tree coding
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Ad

Recently uploaded (20)

Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
Reflections on Morality, Philosophy, and History
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Modelling of Concrete Compressive Strength Admixed with GGBFS Using Gene Expr...
Journal of Soft Computing in Civil Engineering
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...
AI Publications
 

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
  翻译: