Tag Info

New answers tagged


Yes, but it should be the opposite way: DFS is similar to PreOrder. Term PreOrder is more relevant to binary trees and parsers. It is used to compare with other traversal orders of a binary tree: InOrder, PostOrder and PreOrder. Topological Sort is similar to Post Order traversal (push the node into stack after visiting all the adjacent nodes).


The OOP way is to combine together polymorphism and recursion. A binary tree is defined as either empty or a set of value, left and right where both left and right are binary trees. To represent it properly left and right must be binary tree themselves, even if they are empty. To represent that in object oriented way, we'll have a tree base class and node ...

Top 50 recent answers are included