• 0
Sign in to follow this  
KPITALISTA

arvore patricia

Question

eu preciso entregar esse trabalho para a minha professora de pesquisa e ordenação:

//Estudar, especificar (e implementar) as rotinas necessárias à criação e manipulação de uma

//estrutura de ÁRVORE PATRICIA - Practical Algorithm To Retrieve Information Coded In

//Alphanumeric, com obtenção de dados pelo teclado, exemplificando a sua utilização

//(Palavras-chave: árvore PATRICIA, PATRICIA tree)

eu consegui até agora a parte do 'programa de inserção' eo 'programa de consulta', a minha pegunta é como eu implemento esses dois em um programa?

__________________________________________________________________________

//programa de consulta patricia

search(key,t)

typekey key;

patricia t;

{

if(t==NULL)notfound(key);

else

{

while(!IsData(t))

t=bit(t->level,key)? t->right:t->

if(key==t->k)found(t);

else notfound(key);

}

};

___________________________________________________________________

//programa de inserção

patricia insert(key, t)

typekey key;

patricia t;

{

patricia p;

patricia insBetween();

int i;

if(t==NULL) return(NewDataNode(key));

for(p=t;!isData(p);)

p=bit(p->level,key)?p-right:p->left;

/*find first different bit*/

for(i=1;i<=D && bit(i,key)==bit(i,p->k);i++);

if(i>D){error/*key already in table*/;

return(t);}

else return(insBetween(key,t.i));}

patricia InsBetween(key,t,i)

typekey key;

patricia t;

int i;

{patricia p;

if(IsData(t)||i<t->level)

/*create new internal node*/

p=NewDataNode(key);

retur(bit(i,key))? NewIntNode(i,t,p):

NewIntNode(i,p,t);

}

if(bit(t->level,key)==1)

t->right=InsBetween(key,t->right,i);

else t->left=InsBetween(key,t->left,i);

return(t);

};

__________________________________________________________________

fonte: file:///F:/pesquisa%20e%20ordena%C3%A7%C3%A3o/patricia-alg/%C3%81RVORES%20PATRICIA.htm

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this