[amp_mcq option1=”By maintaining a list of visited vertices” option2=”By maintaining a list of traversed edges” option3=”By maintaining a list of non-visited vertices” option4=”By maintaining a list of non-traversed edges” correct=”option1″]
The correct answer is A. By maintaining a list of visited vertices.
A list of visited vertices can be used to keep track of the vertices that have already been visited. This can be done by adding the vertices to the list as they are visited. If a vertex is already in the list, then it is not visited again. This can help to prevent the graph from getting into an infinite loop.
Option B is incorrect because a list of traversed edges does not keep track of the vertices that have been visited. It only keeps track of the edges that have been traversed. This means that it is possible for the graph to visit the same vertex multiple times without the list of traversed edges being updated.
Option C is incorrect because a list of non-visited vertices does not keep track of the vertices that have already been visited. It only keeps track of the vertices that have not been visited. This means that it is possible for the graph to miss a vertex that has already been visited without the list of non-visited vertices being updated.
Option D is incorrect because a list of non-traversed edges does not keep track of the vertices that have already been visited. It only keeps track of the edges that have not been traversed. This means that it is possible for the graph to traverse the same edge multiple times without the list of non-traversed edges being updated.