What are the steps for a depth-first search (iterative approach)?
Overview = edge-based technique, follows each path before backtracking, makes use of stacks and LIFO method
1) Set root vertex as current vertex
2) Add current vertex to list of visited vertices if not already in it
3) Go to every edge connected to current vertex, if linked vertex not in visited list, push to stack and add to visited list
4) When all linked vertices visited, pop off stack and set removed item as current node
5) Repeat from 2) until all vertices visited (stack empty), then output visited nodes
- Outputs can be in different orders depending on which vertex linked to root node the algorithm went to first (most exam boards start at left-most vertex, but all valid nonetheless)