Drzewo wielokierunkowe 'TRIE'

0

Witam wszystkich.
Poszukuje wszystkich informacji na temat drzewa 'trie'. Przeszukałem google, te forum i nigdzie nie ma ani przykładu dodawania, ani wyświetlania.
Jedyne co znalazłem to coś takiego, to jest chyba deklaracje i przeszukiwanie.

One fast but rather wasteful way to implement a trie in Pascal:

type trie = ^ node;
     node = record
               subtrie :array['a'..'z'] of trie;
               IsEndOfWord :boolean
            end;

It is wasteful as a lot of nodes near the edge of the trie will have most subtries set to nil. On the other hand lookup is direct as there is random access on each level/character position in a string.

function find(word:string; length:integer; t:trie):boolean;

   function f(level:integer; t:trie):boolean;
   begin if level=length+1 then
            f:=t^.IsEndOfWord
         else if t^.subtrie[word[level]]=nil then
            f:=false
         else f:=f(level+1, t^.subtrie[word[level]])
   end{f};

begin find := f( 1, t )
end{find}

Za wszystkie info wielkie dzieki.

1 użytkowników online, w tym zalogowanych: 0, gości: 1