UVa 10815

From Algorithmist
Jump to navigation Jump to search

10815 - Andy's First Dictionary[edit]

Summary[edit]

Keep track of how many words are there in the input, defining a word as a contiguous sequence of alphabets, case-insensitive.

Explanation[edit]

There are many ways to do this - with a trie, a binary tree, a set, a hash table, a skiplist, among others.

Gotchas[edit]

  • If you simply read the input word-by-word (like using scanf("%s",word) and cin etc.), the 'word' you get might actually contain multiple words. See the input/output below for the idea.
  • A better alternative would be to handle the input line-by-line and use a "string tokenizer" (like strtok() in C and Class StringTokenizer in java). You might need to think carefully about the (list of) delimiters though.

Implementations[edit]

Input[edit]

this"is"a"really"long"word
good100cats
good22dogs

Output[edit]

a
cats
dogs
good
is
long
really
this
word