depth-first traversal and breadth-first traversal