# DEPTH FIRST SEARCH IN JAVA

21:06

__DEPTH FIRST SEARCH IN JAVA__

public void dfs() { vertex[0].visited=true; displyVertex(0); stackobj.push(0); while(!stackobj.isEmpty()) { int v=adjVertex((Integer) stackobj.peek()); if(v==-1) { stackobj.pop(); } else{ vertex[v].visited=true; displyVertex(v); stackobj.push(v); } } }

## 0 comments