|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Member
Iscritto dal: Apr 2007
Messaggi: 223
|
[C] Algoritmo di Knuth-Morris-Pratt
Sto avendo problemi con quest'algoritmo, non riesco a capire il suo funzionamento, diciamo che la cosa che più mi lascia perplesso è la tabella che viene creata per poter saltare i confronti nella ricerca della sottostringa nella stringa ...
In pratica ho preso sto codice ma non riesco a capire che diamine faccia: Codice:
void kmp_init( F , B ) int F[]; char *B; { int t, s, m=strlen( B ); F[0]=-1; --B; // --F; --B; /* algorithm assumes strings start at index 1 */ t = F[1] = 0; for ( s = 1 ; s < m ; s++ ) { while ( t > 0 && B[s+1] != B[t+1] ) { t = F[t]; } F[s+1] = ( B[s+1] == B[t+1] ) ? ++t : 0; }/*for*/ return; }/*kmp_init()*/ Scusatemi per i miei dubbi idioti ma proprio non riesco a capacitarmi ![]()
__________________
Leaves Web: www.leavesweb.tk Skype: leavesweb Create your dreams! - My Blog: JollyChar! |
![]() |
![]() |
![]() |
#2 |
Member
Iscritto dal: Apr 2007
Messaggi: 223
|
up!
__________________
Leaves Web: www.leavesweb.tk Skype: leavesweb Create your dreams! - My Blog: JollyChar! |
![]() |
![]() |
![]() |
#3 |
Member
Iscritto dal: Apr 2007
Messaggi: 223
|
![]() Nessuno sa darmi una manina piccolina? ![]()
__________________
Leaves Web: www.leavesweb.tk Skype: leavesweb Create your dreams! - My Blog: JollyChar! |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 07:41.