Handling Scenario 1

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.