6. Definition
Digital search tree is one
kind of binary tree which
contains only binary data.
If the bit of DST starts with
0 then it is in left subtree
and if the bit starts with 1
then it is in right subtree
and this process works
recursively.
Slide: 6
7. All keys in the left subtree of a
node at level I. Whose have bit i
equal to zero whereas those in the
right subtree of nodes at this level
have bit i = 1.
New elements require more bits
then previous item. Slide: 7
8. Digital Search Tree
Root contains one dictionary pair (any pair)
All remaining pairs whose key begins with
a 0 are in the left subtree.
All remaining pairs whose key begins with
a 1 are in the right subtree.
Left and right subtrees are digital subtrees
on remaining bits.
Slide: 8
10. A 00001
S 10011
E 00101
R 10010
C 00011
H 01000
I 01001
N 01110
G 00111
X 11000
M 01101
P 10000
A
E S
R XC H
G I N
M
P
Slide: 10
11. Application – IP routing, packet
classification, firewalls.
IPv4 – 32 bit IP address.
IPv6 – 128 bit IP address.
Slide: 11
12. o IPv4 is the fourth generation of internet protocol version and the most
used version.
o IPv6 is the Internet's next-generation protocol and the current version of
internet protocol which replace the IPv4.
o A firewall is a network security system, either hardware or software based,
that controls incoming and outgoing network traffic based on a set of rules.
Slide: 12
14. To insert an element in DST.
There will be four(4) possible cases.
Tree Empty
If found ‘0’, then go left
If found ‘1’ then go right
If found same key, then
insert with prefix equal
Slide:14
28. DST search for key K
For each node T in the tree we have 4
possible results.
T is empty.
K matches T .
Current bit of K is a 0 and go to left child.
Current bit of K is a 1 and go to right child.
Slide: 28
41. Struct node{
int key,info;
struct node *l,*r ;
}
static struct node *head,*z;
unsigned bits(unsigned x, int k, int j)
return (x>>k) & ~(~0<<j);
Int digital_search(int v)
{
struct node *x=head;
int b=maxb; // maxb is the number of bits in the key to besorted
z->key=v;
while(v!=x->key)
x=(bits(v,b--,1) ? x->r : x->l;
return x->info;
}
Slide: 41
43. For each node in the tree we have 3
possible cases.
No child.
One child.
Two children.
Slide: 43
44. Delete in Digital Search Tree
1001
1111
1100
0110
0000 0100
0101 1110
A
B C
D
E F
G
I
Slide: 44
45. Delete in Digital Search Tree
1001
1111
1100
0110
0000 0100
0101 1110
A
B C
D
E F
G
I
Slide: 45
46. Delete in Digital Search Tree
1001
1111
1100
0110
0000 0100
1110
A
B C
D
E F
I
0000
G
Slide: 46
47. Delete in Digital Search Tree
1001
11110110
0000 0100 1110
A
B C
D
E I
Slide: 47
48. Delete in Digital Search Tree
1001
11110110
0000 0100 1100
A
B C
D
E
I
1110
F
0000
G
Slide: 48
49. Delete in Digital Search Tree
1001
1111
0000
0100
11
A
C
D
E
I
1110
F
0101
G
Slide: 49
50. 1.Search key
2. if(key==Node)
free(Node);
if(Node->left==NULL && Node->right==NULL
Do Nothing;
else if(Node->left!=NULL)
Replace Node with next left Node
else if(Node->right!=NULL)
Replace Node with next right Node
else if(Node->right!=NULL && Node->left!=NULL )
Replace Node with next any Node
Slide: 50
51. Insertion, search and deletion in DST are
easier than the Binary search tree and
AVL tree.
This tree does not required additional
information to maintain the balance of
the tree because the depth of the tree is
limited by the length of the key element.
DST requires less memory than Binary
search tree and AVL tree.
Slide: 51
52. Bitwise operations are not always easy.
Handling duplicates is problematic.
Similar problem with keys of different lengths.
Data is not sorted.
If a key is long search and comparisons are
costly, this can be problem.
Slide:52
53. The digital search trees can be
recommended for use whenever the keys
stored are integers
Character strings of fixed width.
DSTs are also suitable in many cases when
the keys are strings of variable length.
Slide: 53