1 / 18

Patricia

Patricia. P ractical A lgorithm T o R etrieve I nformation C oded I n A lphanumeric. 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. Patricia. Uses a header node.

dereklanham
Télécharger la présentation

Patricia

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Patricia • Practical Algorithm To Retrieve Information Coded In Alphanumeric. • 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.

  2. Patricia • Uses a header node. • Remaining nodes define a trie structure that is the left subtree of the header node. • Trie structure is the same as that for the compressed binary trie of previous lecture.

  3. bit# LC Pair RC Node Structure • bit# = bit used for branching • LC = left child pointer • Pair = dictionary pair • RC = right child pointer

  4. 1 0 1 3 2 0 1 0 1 4 4 0 1 0 1 1001 1000 1100 1101 0011 0001 Compressed Binary Trie To Patricia Move each element into an ancestor or header node.

  5. 1000 1100 0011 1101 0001 1001 Compressed Binary Trie To Patricia 0 1 0 1 3 2 0 1 0 1 4 4 1 1 0 0

  6. 0 0000101 0000101 0 5 0000000 Insert Insert 0000101 Insert 0000000

  7. 0000101 0000000 0000101 0000000 0 0 5 5 6 0000010 Insert Insert 0000000 Insert 0000010

  8. 0 0 0000101 0000000 0000010 0000000 0000010 0000101 5 4 0001000 6 5 6 Insert Insert 0001000

  9. 0 0001000 0000000 0000010 0000101 4 5 6 Insert Insert 0000100

  10. 0 0001000 0000000 0000010 0000101 4 5 7 6 0000100 Insert Insert 0001010

  11. 0 0001000 0000000 0000010 0000101 4 5 6 0001010 7 6 0000100 Insert Insert 0001010

  12. Delete • Let p be the node that contains the dictionary pair that is to be deleted. • Case 1: p has one self pointer. • Case 2: p has no self pointer.

  13. 0001000 0000000 p p p Has One Self Pointer • p = header => trie is now empty. • Set trie pointer to null. • p != header => remove node p and update pointer to p.

  14. 0001000 p Blue pointer could be red or black. q y p Has No Self Pointer • Let q be the node that has a back pointer to p. • Node q was determined during the search for the pair with the delete key k.

  15. 0001000 r z p Has No Self Pointer p • Use the key y in node q to find the unique node r that has a back pointer to node q. q y

  16. p 0001000 q y r z y p Has No Self Pointer • Copy the pair whose key is y to node p.

  17. p 0001000 q y r z y p Has No Self Pointer • Change back pointer to q in node r to point to node p.

  18. 0001000 y p Has No Self Pointer p • Change forward pointer to q from parent(q) to child of q. q y r Node q now has been removed from trie. z

More Related