4 votes 4 votes Is this code running fine ?if yes what is the output I am getting 2 here. Algorithms recurrence-relation + – junaid ahmad asked Oct 14, 2017 junaid ahmad 542 views answer comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments junaid ahmad commented Oct 14, 2017 reply Follow Share @ saxena0612 yes given ans is 22 but,I am not sure how it is coming,because whenever we move to left and decrement the node value(1->0),from there on none of left subtree value decremented,similarly in right side,(7->0),they are incrementing x only and that too they are not retuning.?is there anything i am missing here.:( 0 votes 0 votes kash0611 commented Oct 15, 2017 reply Follow Share yes...the code is not returning 'x'...Even if we assume that the code is returning 'x'....still the returned value will be a garbage value since 'x' is uninitialized and incrementing a garbage value results in another garbage value........correct me if i am wrong 0 votes 0 votes Shubhanshu commented Oct 16, 2017 reply Follow Share @junaid ahmad, Understand the role of following statements:- if(root->data %2 == 1) Which means, run the inside code that is, root->data - = 1; only when root->data is an odd value until unless don't decrement. Role of x:- Just to pass your precious time while solving the question, because neither we are propagating this value to further function call nor we are using it in calculation of final answer. At the last they are just asking, SUM OF INTERNAL NODE, which you will get 22. 0 votes 0 votes Please log in or register to add a comment.