Алгоритм/шаги для нахождения Самого Длинного Префикса ищет в Patricia Trie

urlCompression указывает , что сжимать, а httpCompression указывает , как выполнять сжатие. Если вы работаете на IIS7.5, вам ничего не нужно указывать, динамическое и статическое сжатие включены по умолчанию, оба используют gzip; Вот некоторые ссылки на urlCompression и httpCompression .

6
задан vyom 26 May 2009 в 18:07
поделиться

2 ответа

Взгляните на Нет-Патрицию. Это реализация дерева Patricia для поиска IP-адресов. Интерфейс - Perl, но основной код написан на C. Вот ссылка, но она должна быть во многих архивах CPAN:

http://cpansearch.perl.org/src/PHILIPP/Net-Patricia-1.15_07/ libpatricia / patricia.c

4
ответ дан 17 December 2019 в 00:13
поделиться

Если вы используете это дерево для хранения IP-адресов как элементов фиксированной длины, то это определенно неправильный путь. Дело в том, что PT особенно полезен для хранения данных переменной длины.

Если вы храните части IP-номеров в виде префиксов переменной длины, то хорошим выбором будет PT.
In this case yes your keys should be of different length.
Let's say you are storing prefix "192.168" in binary 0xC0 0xA8, you add this as first key.
Then, when searching for IP like 192.168.1.1 you can get information that your trie contains 192.168 which is a prefix of what you look for.

All you have to do is to store the "common part" while traversing the trie.
This is a minor addition to the this implementation. Just make sure that while going down the trie you store the common part somewhere in the parameters of the recursive function.
For good understanding of Patricia trie I would suggest reading Robert Sedgewick's Algorithms book which is a great source of knowledge.

EDIT: There is one problem when storing C strings in PT. This trie is designed to store binary data, but you are interested only in getting the whole bytes. Make sure you are storing common part of the prefix only if its size in bits is multiple of 8. For a wrong example: you have key in your tree: 0xC0 0xA5 and you are looking fro 0xC0 0xA6. Your traversal will stop when the common part "0xC0 0xA", but you are interested in taking only "0xC0". So make sure to store common bytes, not bits.

3
ответ дан 17 December 2019 в 00:13
поделиться
Другие вопросы по тегам:

Похожие вопросы: