# Very simple recursive algorithm

• January 17th, 2013, 07:32 PM
psk_002
Very simple recursive algorithm
Write a recursive algorithm that counts the number of times the integer 0 appears in a list of integers. Write a recurrence for the algorithm and solve it.
• January 17th, 2013, 11:58 PM
BioPhysEngr
Re: Very simple recursive algorithm
[ Moved to its own thread - please do not hijack other threads; new problems should be posted in a new thread ]
• January 17th, 2013, 11:58 PM
BioPhysEngr
Re: Very simple recursive algorithm
As I said before, we can help you learn, not do your homework for you. What progress have you made towards solving this and where are you stuck?
• January 18th, 2013, 11:49 AM
psk_002
Re: Very simple recursive algorithm
ok fine i ll repost in new thread and more over these are not my homework problems. i am new to coding becz my background s biology. i m learng algorithms fr my thesis work. Hope u under stand
• January 18th, 2013, 02:27 PM
MrViggy
Re: Very simple recursive algorithm
Quote:

Originally Posted by psk_002
Write a recursive algorithm that counts the number of times the integer 0 appears in a list of integers. Write a recurrence for the algorithm and solve it.

And, DONE!

Viggy
• February 15th, 2013, 02:10 PM
S@rK0Y
Re: Very simple recursive algorithm
something like that?
Code:

```void cntZeros(int *a, int len, int *cnt, int* index){     if(a[index]==0) *cnt++;     index++;     if(*index<len)cntZeros(a, len, cnt, index);     return; }```
• February 15th, 2013, 07:27 PM
BioPhysEngr
Re: Very simple recursive algorithm
Welcome to the forum and thanks for your constructive comment. That will work, of course, but perhaps we are subtly suggesting he give the problem a try himself. :-) [But it's fine that you responded!]

Also! A helpful forum trick: if you surround your code with [code] and [/code] blocks, it will preserve formatting. I've modified your post to show you how it woks.