For example, what I need to implement at the moment is called the Submission history. This requires me to use data-structure that takes better than O(n) for each of its methods, and someone told me to use
HashMap<studentId, TreeMap<Date, studentScore>>
since,
getBestGrade method: find all submission for student in O(1) and then find best submission in O(N) (You can improve it by caching best score).
So my question is, how would I approach to use caching for the getBestGrade? What I am thinking is, first make a class for the tree-map and add methods of put, remove and getBestGrade in it. Than I just call it back in the another class.
Also, how does the use of caching reduce the time-complexity(big-O)?
Please help... thanks.