Splunk Interview Question

How would you print the nodes in a tree using DFS?

Interview Answer

Anonymous

Feb 23, 2014

void dfs(struct node *root) { if(root == null) { return; } else { dfs(root->left); printf("element: %d",root->data ); dfs(root->right); } }