I am given an already populated Trie T and a set of strings S. I am to compute the sum over the occurences of all elements of S in T. I am a bit confused as to how to go about this.
An example trie is built out of aa, ab and bbb and is supposed to return 9 for S={"b","bb","bb","bbb"}, which seems obvious when looking at the trie (b occurs 4 times, bb twice, and bbb once, so 4+2*2+1 = 9), but I'm not really sure how to calculate this on a larger scale. Any help on the procedure I would have to go through is greatly appreciated.