Depth-first search in Artificial Intelligence is a commonly used approach to traverse the graphs. DFS or Depth-first search traverse through the left subtree first and backtrack to a node that has the right subtree and traverse through the right subtree. In simple words, DFS traverse a tree to the leaf node, backtracks, and explores another path.