extra test, self referencing hashtable
added memoization (java)