I want to write a function to check if two binary trees are the same.
The code looks like:
bool checkSame(Node* first, Node* second) {
// Check if nodes are the same
// Check left nodes: checkSame(first->left, second->left)
// Check right nodes: checkSame(first->right, second->right)
}
The issue is that I'm not sure what to return here. All the implementations of DFS I've found have a void return value. Is there one where it returns a bool?
Also, I'm looking for a recursive solution, not an iterative one.