Skip to content

Tag: optimization

Is JVM or JIT able to reduce duplicate method calls?

I have a function that checks if a map has some value for key (map.get(key) != null) and then returns the value, or else create new value. I’m wondering is there any JVM or JIT magic that doesn’t have to do 2 map lookups when the value exists for the given key? According to my benchmark, it seems …

Using Knapsack approach without value?

Regarding to question, I am wondering that according to the following approach: Assume that there is no value and I am wondering that which approach or algorithm should be used for a Knapsack problem when the values are equal and there is a parameter (called n) that describes times for carrying items in a tim…

How can this Java tree be 1000 x faster?

I am programming an AI for a chess-like game, based on two types of pieces on a 8 x 8 grid. I want to build a kind of minmax tree, which represents each possible move in a game, played by white players in first, and by black players in second. I have this generate() method which is call recursively. I