This is a simple one:

get_power has a complexity of O(logb), since it is dividing b by 2 each time
it is called.
and the get_power func is called for p times.

the overall complexity is O(plog5) , p times O(log5)

On 9 August 2011 09:07, rohit <rajuljain...@gmail.com> wrote:

>  int get_power(int a, int b)
> {
> if(!b)
> return 1;
> if(b%2)
>  return a * get_power(a, b/2);
>  return get_power(a, b/2);
>  }
>
> int func(int p)
> { int sum = 0;
>  for(int i = 1; i <= p; ++i)
> {
> sum += get_power(i, 5);
> }
> return sum;
>
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
___________________________________________________________________________________________________________

Please do not print this e-mail until urgent requirement. Go Green!!
Save Papers <=> Save Trees

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to