To detect both cases of Scenario 1, the priority queue needs to be searched.
However, a linear (O(n)) search of a (possibly large) structure would
take too much time.
Solution: Maintain a hash table "Open" of states that are currently on the priority
queue and check to see if a state has already been created in constant
(O(1)) time.
- When a state is added to/removed from the priority queue, also add it
to/remove it from Open
- When a state is created at expansion time, check for both cases of
Scenario 1 by looking the state up in Open