Looping through all values in a BST to get value to use in another BST

  • #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;
    }
 

Answers and Replies

Suggested for: Looping through all values in a BST to get value to use in another BST

  • Last Post
Replies
6
Views
1K
Replies
4
Views
932
  • Last Post
Replies
6
Views
315
Replies
42
Views
663
Replies
2
Views
398
  • Last Post
Replies
6
Views
464
Replies
2
Views
626
  • Last Post
Replies
4
Views
3K
  • Last Post
Replies
1
Views
342
  • Last Post
Replies
2
Views
401
Top