- #1
softwareTurtle
- 1
- 0
- Homework Statement
- Finish the implementation of buildIndex. You have access to the parameter BST<Path, Ngram[]> files, which contains the 5-grams of each file, as described above. The method should return a BST containing all 5-grams containing in all input files; the value associated with a 5-gram should be the list of files containing that 5-gram (in any order).
Note that the Ngram class already implements the Comparable<Ngram> interface, so you do not need to implement any extra code to be able to compare 5-grams. Also, BST.java is already implemented for you – you do not have to create your own binary search tree implementation.
- Relevant Equations
- for(ArrayList<Path> paths: paths) {
for(Ngram ngrams: files.keys()) {
index.put(ngrams, paths);
}
}
I have a Algorithms and data structure lab that I'm really struggling with. I do not understand how I should iterate over all values to create the new index.
Code:
static BST<Ngram, ArrayList<Path>> buildIndex(BST<Path, Ngram[]> files) {
BST<Ngram, ArrayList<Path>> index = new BST<Ngram, ArrayList<Path>>();
return index;
}