Implement dictionary using java
Posted
by
ahmad
on Stack Overflow
See other posts from Stack Overflow
or by ahmad
Published on 2011-01-02T18:03:20Z
Indexed on
2011/01/02
18:53 UTC
Read the original article
Hit count: 257
Task Dictionary ADT
- The dictionary ADT models a searchable collection of key-element entries
- Multiple items with the same key are allowed
- Applications: word-definition pairs
Dictionary ADT methods:
- find(k): if the dictionary has an entry with key k, returns it, else, returns null
- findAll(k): returns an iterator of all entries with key k
- insert(k, o): inserts and returns the entry (k, o)
- remove(e): remove the entry e from the dictionary
- size(), isEmpty()
Operation Output Dictionary
insert(5,A) (5,A) (5,A)
insert(7,B) (7,B) (5,A),(7,B)
insert(2,C) (2,C) (5,A),(7,B),(2,C)
insert(8,D) (8,D) (5,A),(7,B),(2,C),(8,D)
insert(2,E) (2,E) (5,A),(7,B),(2,C),(8,D),(2,E)
find(7) (7,B) (5,A),(7,B),(2,C),(8,D),(2,E)
find(4) null (5,A),(7,B),(2,C),(8,D),(2,E)
find(2) (2,C) (5,A),(7,B),(2,C),(8,D),(2,E)
findAll(2) (2,C),(2,E) (5,A),(7,B),(2,C),(8,D),(2,E)
size() 5 (5,A),(7,B),(2,C),(8,D),(2,E)
remove(find(5)) (5,A) (7,B),(2,C),(8,D),(2,E)
find(5) null (7,B),(2,C),(8,D),(2,E)
Detailed explanation: NO
Specific requirements: please Get it done i need HELP !!!
© Stack Overflow or respective owner