Search code examples
algorithmtreebinary-treedepth-first-searchpreorder

Is Pre-Order traversal on a binary tree same as Depth First Search?


It seems to me like Pre-order traversal and DFS are same as in both the cases we traverse till the leaf node in a depth wise fashion. Could anyone please correct me if I am wrong?

Thanks in advance!


Solution

  • Pre-order is one type of DFS.

    There are three types of depth-first traversal: pre-order, in-order, and post-order.

    Check out here for more info.