Professional Documents
Culture Documents
Group 912
Find all the anagrams of a given word
An anagram of a word is the result of rearranging the letters of a word to produce a new word,
using all the original letters, and having the same letter frequencies.
12. Define ADT Multimap; representation: dynamic linked list.
13. Define ADT Multimap; representation: hashtable, collision resolution through chaining.
ADT Multimap - dynamic linked list
multimap.h - contains the template for the multimap with class definition, parameters, and
implementation of the class methods
main.cpp - contains the main file of the project, declaring the multimap and loading the file into
it
Operations
TElem = record:
Key: Key
Value: Value
next: ^TElem
nextKey: ^TElem
end record
MultiMap = record:
_size: int
_first: ^TElem
_last: ^TElem
end record
subalg insert(key, value)
if _size = 0 do
s.value <- value
s.key <- sortKey(key)
s.next <- NUL
s.nextKEY <- NUL
else
s <- findKey(sortKey(key))
if s.value = "-1" do
s.value <- value
s.key <- sortKey(key)
s.next <- NUL
s.nextKEY <- NUL
_last.nextKey <- s
_last <- s
else
while s.next != NUL do
s<-s.next
endwhile
s.next <- d
d.nextKey <- NUL
d.next <- NUL
d.value <- value
d.key <- sortKey(key)
endif
endif
_size <- _size + 1
end insert
funct findKey(key)
s <- _first
while s!=NUL do
if s.key = key do
return s
end if
s <- s.nextKey
end while
d.value <- "-1"
return d;
end findKey