Binary Tries - Advanced Data Structures - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Advanced Data Structures which includes Split Algorithm, Unbalanced Binary Search Trees, Forward Pass, Forward Pass Example, Backward Cleanup Pass, Retrace Path, Current Nodes, Roots of Respective Tries, Branch Nodes etc. Key important points are: Binary Tries, Split Algorithm, Unbalanced Binary Search Trees, Forward Pass, Forward Pass Example, Backward Cleanup Pass, Retrace Path, Current Nodes, Roots of Respective Tries, Branch Nodes

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharmakeerti
dharmakeerti 🇮🇳

4.2

(27)

89 documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Binary Tries (continued)
split(k).
Similar to split algorithm for unbalanced binary
search trees.
Construct S and B on way down the trie.
Follow with a backward cleanup pass over the
constructed S and B.
Forward Pass
Suppose you are at node x, which is at level j of
the input trie.
a
x
b
If bit j of k is 1, move to root of b and add
ato level j of S and to level j of B.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Binary Tries - Advanced Data Structures - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Binary Tries (continued)

  • split(k).• Similar to split algorithm for unbalanced binary
  • Construct S and B on way down the trie.search trees.
  • Follow with a backward cleanup pass over theconstructed S and B.

Forward Pass

  • Suppose you are at node x, which is at level j ofthe input trie.

a

x

  • If bit j of k is 1, move to root of b and add^ b

a to level j of S and^ to level j of B.

Forward Pass

  • If bit j of k is 0, move to root of a and add

bto level j of B^ and to level j of S.

a

x

b

Forward Pass Example

b

a

c d e f g

S = null B = null

k = g.key = 101011

Forward Pass Example

d e f g

a

S

c

b

B

k = g.key = 101011

Forward Pass Example

c

a

S

d

b

B

e f g k = g.key = 101011

Forward Pass Example

f g

c

a

S

e

d

b

B

k = g.key = 101011

k = g.key = 101011

Forward Pass Example

d

b

B

e

c

a

S

f

Backward Cleanup Pass Example

e

c

a

S

f

d

b

B

Now backup on B.

Backward Cleanup Pass Example

e

c

a

S

f

d

b

B

Now backup on B.

Backward Cleanup Pass Example

e

c

a

S

f

d

b

B

Now backup on B.

Assume root of is a branch node. d

Backward Cleanup Pass Example

e

c

a

S

f

d

b

B

Complexity ofsplit is O(height).

Compressed Binary Trie

bit# field shown in black outside branch node.

Compressed Binary Trie

#branch nodes = n – 1.

Insert

Insert 0010.

Insert

Insert 0100.

Delete

Delete 1001.

Delete

Split(k)

  • Similar to splitting an uncompressed binarytrie.

Join(S,m,B)

  • Insert m into B to get B’.• |S| <= 1 or |B’| = 1 handled as special cases
  • When |S| > 1 and |B’| > 1, let Sas in the case of uncompressed tries.max be the

largest key in S and let B’key in B’. min be the smallest

  • Let d be the first bit that is different in S and B’min. max

bit#(S) = bit#(B’)

s a b

S

s c d

B’

  • Not possible, because keys in b are larger thanthose in c.
  • However, all keys in S are supposed to be smallerthan those in B’.

bit#(S) < bit#(B’)

s a b

S

b’ c d

B’

s a (^) J(b,B’)

bit#(S) > bit#(B’)

s a b

S

b’ c d

B’

b’ J(S,c) d

Complexity is O(max{height(S), height(B)}).

Smax and B’min are found just once.

PATRICIA

  • P Informationractical Algorithm Coded I Tn oA Rlphanumeric.etrieve
  • Compressed binary trie.• All nodes are of the same data type (binary

tries use branch and element nodes).  Pointers to only one kind of node.

 Simpler storage management.