I think it is overwritng old values when child end..parent overwrite old value with new..m i ryt?
On Thu, Oct 25, 2012 at 3:00 AM, rahul sharma <[email protected]>wrote: > I wana ask that when we pass array by recursion then as we know formal > parameters are passed by value and array by base address/pointre..so in > following program path[] arra contain differnt data each recursive call and > when child function return their data is also deleted i.e when we are at > parent there is only data till parent.So we are having different values in > array in recursion tre..So does it passes by value in recursion.If No then > hw this is implemented??Silly doubt..Please comment....thnx in advance... > Given > a binary tree, print out all of its root-to-leaf paths one per line. > void printPathsRecur(struct node* node, int path[], int pathLen) > { > if (node==NULL) return; > > /* append this node to the path array */ > path[pathLen] = node->data; > pathLen++; > > /* it's a leaf, so print the path that led to here */ > if (node->left==NULL && node->right==NULL) > { > printArray(path, pathLen); > } > else > { > /* otherwise try both subtrees */ > printPathsRecur(node->left, path, pathLen); > printPathsRecur(node->right, path, pathLen); > } > } > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
