C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf

Few year back I had the same problem. I could not understand recursion when there were more than one recursive function. I thought to write a post on it but then I found one that was for me the best to understand recursion. See here : Recursion working Note : Here they have used system.out.println() to print messages as we use printf() in c language. Also check this : Best c compiler for windows

the program contains 2 functions. The first 1 divides the list,in this case, the array into small chunks of items. each chunk having 1 or at most 2 items. here,we use recursion to divide the list into these chunks.

the second function takes these chunks and set it in a temporary array temp[] according to its value. no recursion takes place here. left is 0, right=n-1 and mid=mid index. (u need to preserve the value of left and right.. so put them in variables say l,r) now a variable say t is initialized as 0,or left as left is 0.(it will provide index for temp[]) compare the values in the merge[] for indexes l and mid. in case l is small, inc l by 1. if mid is small inc. mid by 1 and in both the steps put the small value in temp[].

even i learnt it today only. and have some doubts in the final steps. i have no idea about why the penultimate if else statement is used. but i am sure about this much.

#6/3/13.. i guess u have ur exam tomorrow.. even i have.. all the best..

penultimate if else is used for the case when either of the both half gets sorted while the remaining has not been sorted.This if else will sort the remaining part also.

when there is more than one recursive calls then the thing that should be noted is value will be received only in the calling function so u need to be aware that which function is calling and where's my value receiving.

plz give me its algorithm..

ReplyDeletei'm quiet confuse every time when more than two recursion function calling...plzzz give me some idea... & help me to solve such a situation ...

ReplyDeleteFew year back I had the same problem. I could not understand recursion when there were more than one recursive function. I thought to write a post on it but then I found one that was for me the best to understand recursion. See here : Recursion working

DeleteNote : Here they have used system.out.println() to print messages as we use printf() in c language.

Also check this : Best c compiler for windows

Thank you, sir. It works like a charm.

ReplyDeletesame here confused with more than one recursions :( can you give me some ideas

ReplyDeleteJust start drawing recursion tree, Also keep in mind every block or function maintains separate stack of local variables :D

Deletepls give its algo

ReplyDeletethe program contains 2 functions. The first 1 divides the list,in this case, the array into small chunks of items. each chunk having 1 or at most 2 items. here,we use recursion to divide the list into these chunks.

ReplyDeletethe second function takes these chunks and set it in a temporary array temp[] according to its value. no recursion takes place here.

left is 0, right=n-1 and mid=mid index.

(u need to preserve the value of left and right.. so put them in variables say l,r)

now a variable say t is initialized as 0,or left as left is 0.(it will provide index for temp[])

compare the values in the merge[] for indexes l and mid. in case l is small, inc l by 1. if mid is small inc. mid by 1 and in both the steps put the small value in temp[].

even i learnt it today only. and have some doubts in the final steps.

i have no idea about why the penultimate if else statement is used. but i am sure about this much.

#6/3/13.. i guess u have ur exam tomorrow.. even i have.. all the best..

Can u tell the formula for counting the number of times the basic operation is repeated??

ReplyDeletepenultimate if else is used for the case when either of the both half gets sorted while the remaining has not been sorted.This if else will sort the remaining part also.

ReplyDeletewhen there is more than one recursive calls then the thing that should be noted is value will be received only in the calling function so u need to be aware that which function is calling and where's my value receiving.

ReplyDeletewhy max 50 was used

ReplyDeleteusing max 50 is not a must. . . it s just 2 specify the array size. . .

Deletethank u.

ReplyDeleteTHANK YOU SO MUCH

ReplyDeleteLovely Post. Well indented and clean. I found it very useful.

ReplyDeletePlease see this : Java Programming Tutorial