I'm implementing A* (A star) algorithm in Python.
As you know we have have "open set" which consists a list of nodes we plan to explore.
In the algorithm we get the node with lowest F(n) value (estimated total cost) from open set.
We often use PriorityQueue, but for some reason which I don't understand why PriorityQueue doens't get the node with lowest value.
So rather I made an array list (regular list in Python) named "frontier" and keep the "open set" there.
There are two ways to use that like PriorityQueue.
currentNode = min(frontier)
to get the minimum value from the open set.
Or we can sort the array everytime we add new node into it, and just use "pop" to get the lowest value.
#adding a node
frontier.append(someNode)
sorted(frontier)
#taking out the node
currentNode = frontier.pop(0)
Which one is faster?
Using min() or first sorting and then using pop() ?
What algorithm does "min()" in Python use to get the minimum value from an array?