Download presentation

Presentation is loading. Please wait.

Published byIsaak Vile Modified over 2 years ago

1
O ptimal B inary S earch T ree

2
Optimal( 理想 ) Binary ( 二元 ) Search ( 搜尋 ) Tree ( 樹 ) OBST + + + =

3
Preface of OBST It is one special kind of advanced tree. It focus on how to reduce the cost of the search of the BST. It may not have the lowest height. It needs 3 tables to record.

4
Purpose In order to promote the efficiency of the search, we can let the cost of the search minimum or mean the average of compare minimum

5
It has n keys in sorted order (representation k 1,k 2,…,k n ) ( k 1

6
APPLE Bird CatDog Egg Fish Grape dummy keys (d0,d1,…,dn) Keys (k1,k2,..kn)

7
For each key ki, a pi which means the probability searching for ki. For each key di, a qi which means the probability searching for di.

8
elements k n = key p n = probability of searching k n d n = dummy key q n = probability of searching d n

9
Success probability = (i=1~n) ∑ p i Failure probability = (i=0~n) ∑ q i (i=1~n) ∑ p i + (i=0~n) ∑ q i = 1 Success cost = (i=1~n) ∑ p i * (depth(k i )+1) Failure cost= (i=0~n) ∑ q i * (depth(d i )+1) Useful statement

10
E[search cost in ]= Success+ Failure =(i=1~n) ∑ p i * (depth(ki)+1) +(i=0~n) ∑ q i * (depth(di)+1) = (i=1~n) ∑ p i +(i=0~n) ∑ q i +(i=1~n) ∑ p i * depth(ki) +(i=0~n) ∑ q i * depth(di) = 1+(i=1~n) ∑ p i * depth(ki) +(i=0~n) ∑ q i * depth(di)

11
Example#1 i012345 pi 0.1 5 0.1 0.0 5 0.10.2 qi 0.0 5 0.1 0.0 5 0.1 K1K1 K1K1 K2K2 K2K2 K3 K4 K5 K4 K5 d0 d1 d2d3d4d5 d1 d2d3 d4 d5

12
K2K2 d0d0 i012345 pi 0.150.10.050.10.2 qi0.050.10.05 0.1 K 1 =2*0.15=0.3 K 2 =1*0.1=0.1 K 3 =3*0.05=0.15 K 4 =2*0.1=0.2 K 5 =3*0.2=0.6 d 0 =3*0.05=0.15 d 1 =3*0.1=0.3 d 2 =4*0.05=0.2 d 3 =4*0.05=0.2 d 4 =4*0.05=0.2 d 5 =4*0.1=0.4 K4K4 K1K1 K3K3 K5K5 d1d1 d2d2 d5d5 d4d4 d3d3 Cost=Probability * (Depth+1) all cost=2.8

13
i012345 pi 0.150.10.050.10.2 qi0.050.10.05 0.1 K 1 =2*0.15=0.3 K 2 =1*0.1=0.1 K 3 =4*0.05=0.2 K 4 =3*0.1=0.3 K 5 =2*0.2=0.4 d 0 =3*0.05=0.15 d 1 =3*0.1=0.3 d 2 =5*0.05=0.25 d 3 =5*0.05=0.25 d 4 =4*0.05=0.2 d 5 =3*0.1=0.3 Cost=Probability * (Depth+1) K1K1 K2K2 K5K5 K4K4 K3K3 d0d0 d1d1 d5d5 d4d4 d2d2 d3d3 all cost=2.75

14
Picture#1=2.8 Picture#2=2.75 SO Picture#1 cost more than Picture#2 Picture#2 is better. The depth of Picture#1 is 3 The depth of Picture#2 is 4

Similar presentations

OK

Data Structures and Algorithms Lecture (BinaryTrees) Instructor: Quratulain.

Data Structures and Algorithms Lecture (BinaryTrees) Instructor: Quratulain.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on network security concepts Best ppt on forest society and colonialism notes Ppt on series and parallel combination of resistors in parallel Ppt on noise in frequency modulation Ppt on blood stain pattern analysis crime scene Ppt on content addressable memory wiki Ppt on ehv ac dc Ppt on natural resources for class 4 Ppt on polynomials in maths what does median Ppt on surface area and volume of cylinder and cone