you have to calculate the sum of elements which are less than..that
particular element...this is not the question of calculating cumulative sum

On Wed, Mar 14, 2012 at 11:22 AM, sachin sabbarwal <algowithsac...@gmail.com
> wrote:

> @gaurav popli:  how about this one??
>
> findsummat(int arr[],int n)
> {
>    int *sum ;
>      sum =(int*)malloc(sizeof(int)*n);
>
> for(int i=0;i<n;i++)
>   sum[i] = 0;
>
> for(int i=0;i<n;i++)
>    sum[i] = sum[i-1] + arr[i-1];
> //now print the sum array
>
> }
>
> it works very well....
> plz tell me if anything is wrong with this solution.
>
>
> On Tue, Mar 13, 2012 at 12:03 PM, atul anand <atul.87fri...@gmail.com>wrote:
>
>> @piyush : sorry dude , didnt get your algo . actually you are using
>> different array and i get confused which array to be considered when.
>>
>>
>>
>> On Mon, Mar 12, 2012 at 5:19 PM, Piyush Kapoor <pkjee2...@gmail.com>wrote:
>>
>>> 1)First map the array numbers into the position in which they would be,
>>> if they are sorted,for example
>>> {30,50,10,60,77,88} ---> {2,3,1,4,5,6}
>>> 2)Now for each number ,find the cumulative frequency of index ( = the
>>> corresponding number in the map - 1).
>>> 3)Output the cumulative frequency and increase the frequency  at the
>>> position (=the corresponding number in the map) by the number itself.
>>> Example
>>> {3,5,1,6,7,8}  Map of which would be {2,3,1,4,5,6}
>>> Process the numbers now,
>>> 1)3 comes ,find the cumulative frequency at index 1 ( = 2-1) which is 0.
>>> so output 0
>>>    Increase the frequency at index 2 to the number 3.
>>> 2)5 comes,find the CF at index 2( = 3-1) which is equal to 3 .output 3.
>>>    Increase the frequency at index 3 to the number 5.
>>> 3)1 comes,CF at index 0 (=1-1) = 0 so output 0.increase the F at
>>> position 1 by 1.
>>> Similarly for others.
>>>
>>>
>>>  --
>>> 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.
>>>
>>
>>  --
>> 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.
>>
>
>  --
> 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.
>



-- 
*Dheeraj Sharma*

-- 
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