In addition to clarity. Is it possible to do with two marks: is the peak visited or not?

  • @Al g, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky

1 answer 1

In pure DFS, only the Used array can be used. For example:

void dfs(int v) { Used[v] = true; for (...) //для всех доступных из v вершин if (!Used[текущая доступная из v]) dfs(текущая доступная из v); } 
  • And then why the third color? For modified methods? - Al g