Questions tagged [patricia-trie]

Patricia trees are a term for a specialised kind of Radix tree. A radix tree is a space-optimized trie data structure where each node with only one child is merged with its child. This means every internal node has at least two children. Unlike in regular trees, edges can be labeled with sequences of characters as well as single characters. This makes them much more efficient for small sets and for sets of strings that share long prefixes.

According to the Wikipedia article on Radix trees

Donald R. Morrison first described what he called "Patricia trees" in 1968; the name comes from the acronym PATRICIA, which stands for "Practical Algorithm To Retrieve Information Coded In Alphanumeric". Gernot Gwehenberger independently invented and described the data structure at about the same time.


The formal specification for PATRICIA, located in the Journal of ACM Volume 15 Issue 4, Oct. 1968 Pages 514-534 specifies a group of algorithms that produce a tree with very specific requirements. Some examples of those requirements, taken from this document are as follows:

... it was decided that the alphabet should be restricted to a binary one. A theorem which strongly influenced this decision is one which, in another form, is due to Euler. The theorem states that if the alphabet is binary, then the number of branches is exactly one less than the number of ends. Corollaries state that as the library grows, each new end brings into the library with it exactly one new branch, and each branch has exactly two exits. These facts are very useful in the allocation of storage for the index. They imply that the total storage required is completely determined by the number of ends, and all of the storage required will actually be used.

In summary:

  • A PATRICIA data structure has the same structure as a binary tree.
  • There are no 'internal nodes'; "the total storage required is completely determined by the number of ends".
40 questions
3
votes
2 answers

Address book and trie structure

I'have a question for you. I have to implement a business address book that contains 30000 names. All the names contains firstname and lastname. I have to implement an autocomplete textbox that search not only typing firstname but also by…
Mapo
  • 115
  • 1
  • 11
2
votes
1 answer

having problems inserting words on a patricia/radix tree

i am trying to make a code for a college aplication of a patricia/radix tree that inserts words read from each line in a txt file in the tree, so if i read a file that says roman romance romantic its suposed to be implemented like (root) …
2
votes
1 answer

Find all keys in patricia trie that are prefix of a string

I am trying to find all keys stored in a trie that are valid prefixes of a string. Example: Given a trie that contains "ab", "abc", "abcd", "bc" and "bcd". Searching for the string "abcdefg" in the trie should yield "abcd", "abc", "ab". I would…
2
votes
2 answers

Patricia Trie for fast retrieval of IPv4 address and satellite data

I am writing a program in C++ that requires IP addresses( all IPv4) to be looked up and stored in a fast way. Every IP address has a data associated with it. In case it already exists in the trie, I intend to merge the data of the IP address in the…
hytriutucx
  • 1,614
  • 6
  • 26
  • 37
1
vote
0 answers

Is this Patricia tree implementation wrong?

I'm reading the chapter Radix Search of the book Algorithms (Robert Sedgwick). I've made a simple implementation and something isn't behaving as expected. In program 15.5 you can see that we start with an empty tree where the head is a null node. In…
1
vote
0 answers

How would a patricia tree look like after adding a word that starts as the substring of another but has additional letters?

Take this trie as example: I want to add the word "luan" to this representation, but luan takes 20 bits to represent, while lua takes 15. So, they "differ" from each other on the 16th bit, but "lua" has no value there to compare. So how would this…
Jonas
  • 416
  • 4
  • 12
1
vote
0 answers

Difference between a patricia trie (radix tree with r = 2) and a binary trie?

I am trying to consolidate my understanding of the difference between a patricia trie (radix tree with r = 2) and a binary trie. As far as I can see the implementation of a binary trie and a patricia trie (radix tree with r = 2) are identical? Just…
1
vote
1 answer

How to verify that a transaction hash is included in a block's transactionsRoot on chain?

I am doing some research to see how you would verify that a transaction hash is included in the transactionsRoot for a specific block in Ethereum. The challenging part for this is that I am trying to do this on chain. Can anyone help me figure out…
0xKitsune
  • 131
  • 6
1
vote
1 answer

Why Patricia tries has that backwards links in some nodes and what's the logic behing it?

I'm trying to implement my own Patricia Trie library for learning purposes, so i got stuck when adding some nodes because every single example i got have these strange backwards links that makes no sense to me. What's the point of these links?…
1
vote
1 answer

How do I implement a remove/delete function for a Patricia Trie?

I have partially implemented a Patricia Trie, it's still not complete since it lacks a delete/remove function which is used to remove nodes from the Trie, I have found this article describing the structure, which comes with an implementation in C++,…
neevek
  • 11,760
  • 8
  • 55
  • 73
1
vote
0 answers

Trie vs Radix tree vs Patricia trie

As I understand (also from here) memory-complexity of these DSs can be ordered like Trie > Radix > Patricia. But what about time-complexity? I assume they are almost same. If to mention my problem, I want to do a lot of prefix search queries from…
1
vote
1 answer

Why `floorEntry` and other methods are not accessible in PatriciaTrie?

While implementing an ip-lookup structure, I was trying to maintain a set of keys in a trie-like structure that allows me to search the "floor" of a key (that is, the largest key that is less or equal to a given key). I decided to use Apache…
ale64bit
  • 6,232
  • 3
  • 24
  • 44
1
vote
1 answer

How does one build a Radix Tree in JavaScript?

Inspired by iOS7 iMessage's next-word-prediction, I've decided to try to write a script that will learn, based on user input, which words / letters are most likely wanted to complete the user's current word or which word might most likely be desired…
user2076675
1
vote
1 answer

Proto-Buf.Net and serialization

I've a problem with serializing an object using protobuf.net. I've used it on other classes and it works very well, but using this it doesn't. Could you help me saying why. Thanks. I want to use protobuf because BinaryFormatter is very slow in…
Mapo
  • 115
  • 1
  • 11
0
votes
1 answer

Do I need to supply the branch node if I don't need the value in it in a Patricia tree?

For example, in this PATRICIA tree, if I want to prove that the key 'fc' has no value mapped to it, should I bring up the branch node stored the data value “b” even though I don't need the data value?