Suppose I have a list of vertices in a graph. This list corresponds to a path in the graph and before adding another vertex I need to check if it is already present in the path or not.
I was thinking of adding all the vertices in an unordered set and then using the find function. The documentation states that it runs in constant time in an average case. Would it still run in constant time in this case?
If not, is there a way to store a list of vertices and find if a vertex exists in the list or not in constant time?