blob: 0ac38a82568210edd958033748052982afab6231 [file] [log] [blame]
/*
/*Insert
/*******************/
/****************/
/*End
/*Print
Implementation
Insert
of
or
ort();
ord);
ot
otherChar;
os
ostfix,
t
the
typedef
tr
trie
trie));
tr,String
tr)
tr);
trInit(void)
trInit(void);
trInit();
tr->val)
tr->word
tr->postfix
tr->otherChar
tr->t
tr;
tNew(char
tNew(*w);
tAlloc(void)
tAlloc(void);
tAlloc();
t,
t;
t->val
t->val);
t->word
t->data
t->postfix
t->otherChar
tmp
tmp;
turn;
t(0);
d
datastructure
data;
deleteWord(Trie
deleteW(Trie
deleteNode(Trie
deleteChar(SString
deleteChar(word);
does
don't
d->len]
Trie
TrieRoot
TrieRoot;
TrieRoot));
Trie")
True
True;
True)
)
);
September
Schmidt
SString
SString;
SString));
String
String;
Should
1996
1000
1;
1);
Lars
LINESIZE
LE
Hjorth
Nielsen
NULL)
NULL;
NON-EMPTY
NON-NULL
a
an
and
abort();
ar,
argc,
ak;
Jacob
Winstrup
*
*/
*Trie;
*)
*=
**argv)
#include
#define
e
else
error("Cannot
emp
empty
en++]
eturn
exit(0);
e,
<
<stdio.h>
<stdlib.h>
<string.h>
<sourcefile>\n",argv[0]);
-1
->t
->s
->max
->len
False
False;
FILE
0
0;
0)
0);
||
&
&&
MAXSIZE
500
struct
string.
strcpy(tmp,
strlen(word)
stfix,
ssInit(void)
ssInit(void);
ssInit();
s;
sizeof(struct
sizeof(char)
sizeof(char)+1);
se
sTemp
sTemp;
s);
f
function
functions
fix
file;
free(word->s);
fprintf(stdout,
fopen(argv[1],
fseek(file,
fclose(file);
in
int
insert
insertWord(TrieRoot
insertWord(tr,
insertW(Trie
insertW(r->t,
insertW(tr->postfix,
insertW(tr->otherChar,
insertRestOfWord(String
insertRestOfWord(w);
insertRestOfWord(++w);
insertChar(SString
insertChar(word,
ing
ie
if
if(argc
if(!(file
id
bool
bool;
bort();
but
buffer[MAXSIZE];
be
break;
c
char
c)
c);
ct
calloc(1,
c;
count
void
val;
w)
w);
word
word,
word)
word);
word;
word->s
word->s);
word->s[word->len++]
word->s[word->len]
word->s[--word->len]
word->max
word->max)
word->len
word[LINESIZE];
w++;
while(!feof(file))
printT(TrieRoot
printT(tr);
printTheRest(Trie
printTheRest(tr->t,
printTheRest(t->postfix,
printTheRest(t->otherChar,
printf("%s\n",
pos
postfix;
pos,
perror(argv[1]);
{
r
return
return;
rn
rn;
r,
r,String
r->t
r->t,
rt();
rd
rd->max
rd->len
rd->s
l
len;
lse
}
};
n
ng
not
n;
new
n",
max
max;
main(int
must
=
==
(Trie)
(TrieRoot)
(t
(tr
(tr->postfix
(tr->otherChar
(tmp
(t->word
(void
(*w
(*(w+1)
(r->t
(word
(word->s
(word->len
(String)
(SString)
(sTemp
();
(fscanf(file,"%s",word)
x
'\0')
'\0';
>
>t,
>postfix
>len]
;
happen
har
harm.
+
++w);
\0
\0")
2
2;
2)
OK
Char,
!=
ut,
"Usage:
"r")))
%s
[1]);
exit 0