-
Following are the few test cases which you should use to test your code. Feel free to add other corner cases if not already covered.
-
Please use the following test cases to test your code using Testing Frameworks/Testing Tools like CPPUNIT for C++ or JUnit for Java, please use appropriate tool for your programming language.
- AddValue (Value) : Insert Value into the Cache.
- LookUpValue (Value) : Check if Value is there and increment Frequency.
- EvictFromCache () : Remove least Frequent Element.
- PrintLFU () : Print the Elements in LFU. Format = Frequency: List of Elements.
- AddValue (5)
- AddValue (4)
- AddValue (3)
- AddValue (4)
- LookUpValue (5)
- PrintLFU ()
Count 1: 3
Count 2: 4,5
- EvictFromCache ()
- PrintLFU ()
Count 2: 4, 5
- EvictFromCache ()
- PrintLFU ()
'Nothing or simply Return'
- EvictFromCache ()
- LookUpValue (1)
- AddValue (1)
- PrintLFU ()
Count 2: 1
- AddValue (2)
- PrintLFU ()
Count 1: 2
Count 2: 1
- AddValue (1)
- AddValue (1)
- AddValue (1)
- AddValue (2)
- AddValue (2)
- AddValue (3)
- PrintLFU ()
Count 1: 3
Count 2: 2
Count 3: 1
- EvictFromCache ()
- PrintLFU ()
Count 2: 2
Count 3: 1
- AddValue (2)
- PrintLFU ()
Count 3: 1, 2
- EvictFromCache()
- PrintLFU ()
Count 3: 1
OR
Count 3: 2 (Depends on Implementation.)