Re: [algogeeks] Re: FUN TEASER 11 may

2011-05-12 Thread arjoo kumar
good answer

On Wed, May 11, 2011 at 8:52 PM, anil chopra wrote:

> i will stop imaging.
>
>
> On Wed, May 11, 2011 at 7:38 PM, Dave  wrote:
>
>> I was on a river boat in Europe, and the emergency drill was to go to
>> the upper deck and wait, high and dry, for the boat to sink into the
>> muddy river bottom.
>>
>> Dave
>>
>> On May 11, 2:09 am, Lavesh Rawat  wrote:
>> > *FUN TEASER
>> >  *
>> > *
>> > *
>> > **
>> > *Imagine you are alone in a boat in the middle of a river. Suddenly the
>> boat
>> > starts to sink. You don't know swimming and no one is around to help
>> you.
>> > How do you get out of the situation?
>> > *
>> >
>> > *Update Your Answers at* : Click
>> > Here<
>> http://dailybrainteaser.blogspot.com/2011/05/fun-teaser-11-may.html?l...>
>> >
>> > Solution:
>> > Will be updated after 1 day
>> >
>> > --
>> >
>> > "Never explain yourself. Your friends don’t need it
>> and
>> > your enemies won’t believe it" .
>>
>> --
>> 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.



Re: [algogeeks] Inversion Count

2011-05-12 Thread anshu mishra
no all these data structure also take time O(nlogn)

solving this problem using segment tree

map all elements to its index on the sorted array.

ex. 2 3 8 6 1 --> 1 2 4 3 0

intialiize all element in segment tree wid zero

start from the last index of array

whenever u visit a node increase its value by 1 --> one more value came in
this range

if u have go right child then increase the count by number of element in
left child(that is value left node). thats it;

void query(int a, int s, int e, int node, unsigned long long &count)
{
int mid = (s+e)>>1;
tree[node] += 1;
if (s == e) return;
if (a <= mid)
{
query(a, s, mid, (node<<1)+1, count);
}
else
{
count += tree[(node<<1)+1];
query(a, mid+1, e, (node<<1)+2, count);
}
return;
}

I have written another code using ur logic its giving correct answer. I m
not getting where u r wrong. :P

#include 

unsigned long long int merge_and_count (int *a, int start, int mid, int end)
{
int len_a = mid - start + 1;

int len_b = end - mid;
int C[end - start + 1];
int k = 0;
int i = start;
int j = mid + 1;
unsigned long long int count = 0;
int rem = len_a;

while ( i <= mid && j <= end ) {

C[k++] = a[i] < a[j] ? a[i] : a[j];
if ( a[j] <= a[i] ) {
count += rem;
j++;
} else {
i++;
rem--;
}
}

while ( i <= mid ) {
C[k++] = a[i++];
}

while ( j <= end ) {

C[k++] = a[j++];
}

for ( i = start; i <= end; i++ ) {
a[i] = C[i-start];
}

return count;
}

unsigned long long int sort_and_count(int *a, int start, int end)
{
int mid;

unsigned long long int rA, rB, r;

if ( end == start )
return 0;
else {
mid = (start + end) >> 1;
rA = sort_and_count (a, start, mid);
rB = sort_and_count (a, mid + 1, end);
r = merge_and_count (a, start, mid, end);

} return (rA+rB+r);
}

int main()
{
int t, n, i;
int a[200100];

scanf ("%d", &t);

while ( t-- ) {
scanf ("%d", &n);

for ( i = 0; i < n; i++ ) {

scanf ("%d", &a[i]);
}

printf ("%llu\n", sort_and_count(a, 0, n - 1));
}

return 0;
}

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



Re: [algogeeks] Google Q

2011-05-12 Thread ArPiT BhAtNaGaR
if u knw the no. of 1's in no .
I mean can afford the complexity of finding no. of 1's of no.


den if no of 1'
in say 101011
 is 4   den largest is00
smalest is   00

On Fri, May 13, 2011 at 8:38 AM, Ashish Goel  wrote:

> Given an integer, print the next smallest and next largest numbers that
> have the same number of 1’s in their binary representations
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> 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.
>



-- 
Thanks & Regards

Arpit Bhatnagar
(Computer Engineering)
(MNIT JAIPUR)

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



[algogeeks] Google Q

2011-05-12 Thread Ashish Goel
Given an integer, print the next smallest and next largest numbers that have
the same number of 1’s in their binary representations


Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652

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



[algogeeks] Google Q

2011-05-12 Thread Ashish Goel
Using bit manipulation, implement add, subtract and multiply on two
integers. You cannot use any arithmetic operations, such as +, - or *.


Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652

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



[algogeeks] Tivoli Engineer/Administrator Needed in IL

2011-05-12 Thread Leon Parker
Hello Associates,

Please go through the below requirement and let me know if you have any
consultants for the below position?
*
Job Title: Tivoli Engineer/Administrator
Location: Chicago, IL
Duration: 6 Months

Telephonic and Skype interview -- No F2F

Again, looking for TSM engineers with implementation and admin experience.
Local candidates preferred.  No netbackup, commvault or legato people.*

Thanks
Leon Parker - l...@panzersolutions.com
203-983-9475

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



Re: [algogeeks] Re: Need help on Divide and Conquer Algorithm

2011-05-12 Thread pacific :-)
a sort and another traversal would also do the same job in o( nlogn + n )
??

On Fri, Apr 15, 2011 at 12:49 AM, vishwakarma
wrote:

> complexity : O(n) + O(nlogn)
>
> Sweety wrote:
> > Question :Let A[1..n] be an array of integers. Design an efficient
> > divide and conquer algorithm to determine if A contains a majority
> > element, i.e an element appears more than n/2 times in A. What is the
> > time complexity of your algorithm?
> >
> > Answer:
> > a[1..n] is an array
> > int majorityElement(int a[], int first, int last)
> > {
> >  If (first = = last)
> > {
> >return a[first]; // Array has one element and its count =
> 1
> > and it is major element
> >  }
> > mid= (first+last)/2;
> >
> >(majorL,countL)= majorityElement(a,first,mid);
> >(majorR,countR)= majorityElement(a,mid
> > +1,last);
> > n = total elements in an array;
> >   If(majorL==majorR)
> > return(countL+countR);
> >  else
> >  {
> >If(countL>countR)
> > return(majorL,countL);
> >   elseif(countL< countR)
> > return(majorR,countR);
> >   else
> >return(majorL,majorR);
> >   }
> >  if(countL>n/2)
> > temp1=majorL;
> >   if(countR>n/2)
> >  temp2=majorR;
> >
> >If(temp1 = = temp2)
> >   return temp1;
> >   elseif(countL>countR)
> >  return temp1;
> >  else (countR>countL)
> > return temp2;
> > else
> >   return -1;
> > }
> >
> > int main()
> > {
> >   int a[8] = {2,3,2,2,4,2,2,2};
> >   int first =1;
> >   int last=8;   //change the value of last when the array
> > increases or decreases in size
> >   int x = majorityElement(a,first,last);
> >   if(x= = -1)
> > printf(“No Majority Element”)
> >   else
> >   Majority element = x;
> >  }
>
> --
> 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.
>
>


-- 
regards,
chinna.

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



Re: [algogeeks] Finding subarray

2011-05-12 Thread pacific :-)
myapproach( set S , sum s ) :
Let all elements be set  S  and we need to find sum , s
1. for each element taken from the set ,e
2. now call the function recursively with   myapproach( S - { e } , s - e )
and myapproach( S - {e } , s )

On Mon, Apr 11, 2011 at 3:17 PM, Subhransu wrote:

> I didnt get the step 3. Could you please elaborate this(dry run be good to
> understand and bringing it for generic solution).
> Also how best the complexity will be .
>
> *Subhransu Panigrahi
> *
> *Mobile:* *+91-9840931538*
>  *Email:* subhransu.panigr...@gmail.com
>
>
>
> On Mon, Apr 11, 2011 at 12:27 AM, ArPiT BhAtNaGaR <
> arpitbhatnagarm...@gmail.com> wrote:
>
>> well i hav deviced a approach :
>>
>>
>> well say we hav sorted array  {-1 -3 2 3 3 5 9 13 24}
>>
>> say we hav to seach 6
>>
>> take sum of all neg no   store it   -4   means we can atmost reduce any no
>> by 4 units means in any case we cant take no greater than 10-4=6 for finding
>> 6.
>>
>> now locate the upto position just less than we r searching for here 9
>>
>> now sum up all positive upto 9 3+2+3+3+5 ie 16   now
>>
>> WE hav 3 sets
>>
>> (1)   negative no sum
>> (2) postive no less than requred sum
>> (3)  greater no set  we can easily check here since only of
>> this set less than 10 is useful so we hav 9 check for 9 & -1 & -3 here
>> we get 6.
>>
>> either way we hav 16 & -4 need some thing done here
>>
>>
>>
>>
>> NOT PURE SOLN JUST AN IDEA THOUGH GOOD TO BE SHARE
>>
>>
>>
>>
>>
>>
>> On Thu, Mar 31, 2011 at 1:06 AM, Subhransupanigrahi <
>> subhransu.panigr...@gmail.com> wrote:
>>
>>> could you please point to some similar
>>> I just want to validate the approach which I am thinking of.
>>>
>>>
>>> Sent from my iPhone
>>>
>>> On Mar 31, 2011, at 0:59, hammett  wrote:
>>>
>>> > We did :-)  Dynamic programming seems as the best way to approach this
>>> > kind of problem.
>>> >
>>> > On Wed, Mar 30, 2011 at 12:56 AM, Subhransu
>>> >  wrote:
>>> >> For this X = {-1,4,2,3}
>>> >> Nearest will be 4 then remain is 1 but the there is no 1 so again in
>>> >> recursion nearest number is 2 then it search for suitable number where
>>> the
>>> >> sum is zero so 3 is not suitable then it will pick the next closest
>>> number
>>> >> to 2 which is one and make it (5= 4 + 2 -1 )
>>> >>
>>> >> I just propose one approach you guys also can think a better one.
>>> >>
>>> >> Subhransu Panigrahi
>>> >>
>>> >> Mobile: +91-9840931538
>>> >>
>>> >> Email: subhransu.panigr...@gmail.com
>>> >>
>>> >>
>>> >> On Wed, Mar 30, 2011 at 12:55 PM, Saikat Debnath <
>>> crazysai...@gmail.com>
>>> >> wrote:
>>> >>>
>>> >>> @ Subhranshu : Your approach will fail for a case let  X = {-1,4,2,3}
>>> and
>>> >>> your sum is 5. You will get nearest element 4, but there is no 1 in
>>> the set.
>>> >>> A DP solution will be like this :
>>> >>> Let a[i][j] be the 1 if using the first i elements we can get sum of
>>> j,
>>> >>> and 0 otherwise. Initialise a[0][j] = 0, a[i][0] = 1;
>>> >>> Now a[i][j] = a[i-1][j] | a[i-1][ j - X[i] ], where X[i] is ith
>>> element of
>>> >>> set X.
>>> >>>
>>> >>> On Wed, Mar 30, 2011 at 12:35 PM, hammett  wrote:
>>> 
>>>  I'd try a tabular approach. Check dynamic programming. Samples like
>>>  LCS may give you a click.
>>> 
>>> 
>>>  On Tue, Mar 29, 2011 at 11:46 PM, Subhransu
>>>   wrote:
>>> > set of integers in an array X that the sum equals a given number N
>>> >
>>> > Eg. X = {-1, -3, 5, 13, 2, 24, 9, 3, 3}
>>> >
>>> > Lets say the number 5 which can be formed in the following manner
>>> 5= 2
>>> > + 3
>>> > (the values from array). If there is no match it has to return
>>> > invalid numbers.
>>> >
>>> > We also have to see the complexity of the solution.
>>> >
>>> > I thought of one approach but not sure if there is more approach
>>> where
>>> > the
>>> > complexity will be minimal.
>>> > Lets say sort the array and now take number and find the closest
>>> number
>>> > for
>>> > that.
>>> > Then in a recursion manner search for another( Lets say number '5',
>>> it
>>> > search the list and found closest match
>>> > will be 3. Then recursively search for 3 now where closest match is
>>> 2)
>>> >
>>> > Any algo with better complexity will be appreciated.
>>> >
>>> > Subhransu Panigrahi
>>> >
>>> > Email: subhransu.panigr...@gmail.com
>>> >
>>> > --
>>> > 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.
>>> >
>>> 
>>> 
>>> 
>>>  --
>>>  Cheers,
>>>  hammett
>>>  http://hammett.castleproject.org/
>>> 
>>>  --
>

Re: [algogeeks]

2011-05-12 Thread pacific :-)
Just a try for :

You have a billion urls, where each has a huge page. How to you detect the
duplicate documents?

1. Compute a simple hash for each of the document.
2. And for those docs where the hash matches ,
3.  use a different hash function and go back to step 1..

you might want to stop when u after a certain similarity.

On Thu, May 5, 2011 at 7:33 PM, sourabh jakhar wrote:

> You have a billion urls, where each has a huge page. How to you detect the
> duplicate documents?
>
> --
> SOURABH JAKHAR,(CSE)(3 year)
> ROOM NO 167 ,
> TILAK,HOSTEL
> 'MNNIT ALLAHABAD
>
>  The Law of Win says, "Let's not do it your way or my way; let's do it the
> best way."
>
>  --
> 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.
>



-- 
regards,
chinna.

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



Re: [algogeeks] exon chaining

2011-05-12 Thread pacific :-)
Can you provide example input and output ?

On Thu, May 12, 2011 at 9:32 AM, ganesha  wrote:

> Can some one help in finding out the bug in the below code.
>
> Input: (left,right,weight) representing intervals
> Output: maximum weight of non-overlapping intervals
>
> #include 
> #include 
> #include 
> #include 
>
> struct point
> {
>int value;
>bool isLeft;
>long int weight;
>int index;
>struct point* prev;
> };
>
> typedef struct point* NODEPTR;
>
> bool compare (NODEPTR A,NODEPTR B)
> {
>return (A->value < B->value);
> }
>
> int main()
> {
>
>int numIntervals;
>cin >> numIntervals;
>
>// read the intervals and sort the list
>vector points;
>
>for (int i=0; i < numIntervals; i++)
>{
>NODEPTR p1 = new point;
>p1->isLeft = true;
>p1->weight = 0;
>p1->prev = NULL;
>cin >> p1->value;
>points.push_back(p1);
>
>NODEPTR p2 = new point;
>p2->isLeft = false;
>p2->prev = p1;
>cin >> p2->value;
>cin >> p2->weight;
>points.push_back(p2);
>}
>
>sort(points.begin(),points.end(),compare);
>
>
>vector::iterator it;
>int idx=1;
>for (it=points.begin(); it!=points.end(); ++it)
>{
>(*it)->index = idx++;
>}
>
>/*for (it=points.begin(); it!=points.end(); ++it)
>{
>if ((*it)->prev != NULL)
>cout << (*it)->prev->value << " " << (*it)->value <<
> " " << (*it)-
> >weight << " " << (*it)->prev->index << endl;
>}*/
>
>
>int score[2*numIntervals + 1];
>for (int i=0; i <= 2*numIntervals; i++)
>{
>score[i] = 0;
>}
>
>int i = 1;
>for (it=points.begin(); it!=points.end(); ++it)
>{
>// right end of the interval
>if (false == (*it)->isLeft)
>{
>int j = (*it)->prev->index;
>
>int t1 = score[j] + (*it)->weight;
>int t2 = score[i-1];
>
>if (t1 < t2)
>score[i] = t2;
>else
>score[i] = t1;
>}
>else
>{
>score[i] = score[i-1];
>}
>
>i++;
>}
>
>cout << "Max weight is " << score[2*numIntervals] << " " <<
> 2*numIntervals << endl;
>
>return 0;
> }
>
> --
> 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.
>
>


-- 
regards,
chinna.

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



Re: [algogeeks]

2011-05-12 Thread Gaurav Aggarwal
SPAM.. moderator please delete this post..

On Thu, May 12, 2011 at 7:00 PM, SANDEEP CHUGH wrote:

> http://www.PaisaLive.com/register.asp?3176949-6719896
>
> CHECK IT
>
> --
> 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.
>



-- 
Gaurav Aggarwal
SCJP

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



Re: [algogeeks] Re: FUN TEASER 11 may

2011-05-12 Thread Kunal Patil
@ Anil: +1 dude...Nice answer...

On Wed, May 11, 2011 at 8:52 PM, anil chopra wrote:

> i will stop imaging.
>
>
> On Wed, May 11, 2011 at 7:38 PM, Dave  wrote:
>
>> I was on a river boat in Europe, and the emergency drill was to go to
>> the upper deck and wait, high and dry, for the boat to sink into the
>> muddy river bottom.
>>
>> Dave
>>
>> On May 11, 2:09 am, Lavesh Rawat  wrote:
>> > *FUN TEASER
>> >  *
>> > *
>> > *
>> > **
>> > *Imagine you are alone in a boat in the middle of a river. Suddenly the
>> boat
>> > starts to sink. You don't know swimming and no one is around to help
>> you.
>> > How do you get out of the situation?
>> > *
>> >
>> > *Update Your Answers at* : Click
>> > Here<
>> http://dailybrainteaser.blogspot.com/2011/05/fun-teaser-11-may.html?l...>
>> >
>> > Solution:
>> > Will be updated after 1 day
>> >
>> > --
>> >
>> > "Never explain yourself. Your friends don’t need it
>> and
>> > your enemies won’t believe it" .
>>
>> --
>> 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.



[algogeeks]

2011-05-12 Thread SANDEEP CHUGH
http://www.PaisaLive.com/register.asp?3176949-6719896

CHECK IT

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



[algogeeks] Study Online For Diploma..

2011-05-12 Thread Geo News
*Study Online For Diploma
Study at Your Own Time & Own Pace Globally Recognized Diploma Courses
http://bit.ly/degreeZ

http://bit.ly/degreeZ

---
*

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



Re: [algogeeks] Inversion Count

2011-05-12 Thread Akshata Sharma
@Anshu:
My logic:
during merge step, lets say you have two array left and right (both are
sorted) and you are going to merge it.

l[i] represent the element of left arrray
r[j] represent the element of right array

if (r[j] < l[i]) {
  increase the inversion count by the number of elements lefts in left array
  put element r[j] into merged array
  j++
} else {
  no increase in count, just put the element r[i] into merged array
  i++;

This will be O(nlogn) solution. Can we do better using BIT or segment trees?
Can you please provide me some hint of how to solve it using segment trees,
I just know the basics of it..
On Thu, May 12, 2011 at 5:00 PM, anshu mishra wrote:

> explain your logic instead of posting code, use binary index tree or
> segment tree or bst to solve this problem.
>
> --
> 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.



Re: [algogeeks] Inversion Count

2011-05-12 Thread anshu mishra
explain your logic instead of posting code, use binary index tree or segment
tree or bst to solve this problem.

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



[algogeeks] Inversion Count

2011-05-12 Thread Akshata Sharma
I tried to solve this problem using merge sort logic, the algorithm is same
as merge sort, only change is in the merge step where i am counting the
inversion_count.
I tested some test cases and I am getting correct answer,  but I am getting
WA on spoj. Is the code incorrect or any test case whr it fails?

http://www.spoj.pl/problems/INVCNT/


#include
using namespace std;

long inversion_count = 0;

void merge(long arr[], long p, long q, long r)
{
 long n1 = q-p+1;
 long n2 = r-q;
 long L[n1];
 long R[n2];

 for(long i=0;iR[j])
 {
  arr[k]=R[j];
  j++;
  k++;
  inversion_count+=n1-i;
 }
}
}

void merge_sort(long arr[], long p, long r)
{
 if(phttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-05-12 Thread Gaurav Aggarwal
To ADMIN / MODERATOR: please delete this thread.. these mails are really
irritating..

On Thu, May 12, 2011 at 2:11 PM, inderpal singh wrote:

> me too pls
> inderpal...@gmail.com
>
>
> On Mon, May 9, 2011 at 12:07 AM, vamsi achyuth wrote:
>
>> mail tome plz
>> vamsiachy...@gmail.com
>>
>>
>> On 8 May 2011 22:00, UTKARSH SRIVASTAV  wrote:
>>
>>> mail me also usrivastav...@gmail.com
>>>
>>>
>>> On Sun, May 8, 2011 at 1:08 AM, ArPiT BhAtNaGaR <
>>> arpitbhatnagarm...@gmail.com> wrote:
>>>
 dere is soln first person mail to first person on list n den the one who
 gets to next & so since we all need it :P


 On Fri, May 6, 2011 at 11:01 AM, vamsi achyuth 
 wrote:

> mail me++;
>
>
> On 6 May 2011 10:52, naresh kumar  wrote:
>
>> Pleas mail to me also...
>> naresh.sac...@gmail.com
>> Thanks in advance
>>
>>
>> On Fri, May 6, 2011 at 1:46 AM, Ashish Modi 
>> wrote:
>>
>>> Hello,
>>> Can  you please mail me ashishrmod...@gmail.com
>>>
>>> Thanks in advance
>>>
>>> --
>>> With Regards
>>> Ashish
>>>
>>> --
>>> 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.
>



 --
 Thanks & Regards

 Arpit Bhatnagar
 (Computer Engineering)
 (MNIT JAIPUR)

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

>>>
>>>
>>>
>>> --
>>> *UTKARSH SRIVASTAV
>>> CSE-3
>>> B-Tech 2nd Year
>>> @MNNIT ALLAHABAD*
>>>
>>>
>>>  --
>>> 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.
>



-- 
Gaurav Aggarwal
SCJP

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



Re: [algogeeks] [brain teaser ] WHO IS SHORTEST 12 may

2011-05-12 Thread rupali chauhan
nancy
it was so easy


On Thu, May 12, 2011 at 12:51 PM, Piyush Sinha wrote:

> NANCY
>
>
> On Thu, May 12, 2011 at 12:45 PM, Lavesh Rawat wrote:
>
>>*WHO IS SHORTEST
>>  *** **
>> *
>> *
>> **
>> *Johnny is taller than Kitty and Carol. Kitty is taller than Sam. Kitty
>> and Sam are taller than Nancy. Sam is shorter than Carol. Who is the
>> shortest?
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need it
>> and your enemies won’t believe it" .
>>
>> --
>> 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.
>>
>
>
>
> --
> PIYUSH SINHA
> 9936757773
>
>  --
> 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.



Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...

2011-05-12 Thread inderpal singh
me too pls
inderpal...@gmail.com

On Mon, May 9, 2011 at 12:07 AM, vamsi achyuth wrote:

> mail tome plz
> vamsiachy...@gmail.com
>
>
> On 8 May 2011 22:00, UTKARSH SRIVASTAV  wrote:
>
>> mail me also usrivastav...@gmail.com
>>
>>
>> On Sun, May 8, 2011 at 1:08 AM, ArPiT BhAtNaGaR <
>> arpitbhatnagarm...@gmail.com> wrote:
>>
>>> dere is soln first person mail to first person on list n den the one who
>>> gets to next & so since we all need it :P
>>>
>>>
>>> On Fri, May 6, 2011 at 11:01 AM, vamsi achyuth 
>>> wrote:
>>>
 mail me++;


 On 6 May 2011 10:52, naresh kumar  wrote:

> Pleas mail to me also...
> naresh.sac...@gmail.com
> Thanks in advance
>
>
> On Fri, May 6, 2011 at 1:46 AM, Ashish Modi 
> wrote:
>
>> Hello,
>> Can  you please mail me ashishrmod...@gmail.com
>>
>> Thanks in advance
>>
>> --
>> With Regards
>> Ashish
>>
>> --
>> 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.

>>>
>>>
>>>
>>> --
>>> Thanks & Regards
>>>
>>> Arpit Bhatnagar
>>> (Computer Engineering)
>>> (MNIT JAIPUR)
>>>
>>>  --
>>> 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.
>>>
>>
>>
>>
>> --
>> *UTKARSH SRIVASTAV
>> CSE-3
>> B-Tech 2nd Year
>> @MNNIT ALLAHABAD*
>>
>>
>>  --
>> 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.



Re: [algogeeks] [brain teaser ] WHO IS SHORTEST 12 may

2011-05-12 Thread vaibhav shukla
NANCY. so easy that was

On Thu, May 12, 2011 at 3:21 AM, Piyush Sinha wrote:

> NANCY
>
>
> On Thu, May 12, 2011 at 12:45 PM, Lavesh Rawat wrote:
>
>>*WHO IS SHORTEST
>>  *** **
>> *
>> *
>> **
>> *Johnny is taller than Kitty and Carol. Kitty is taller than Sam. Kitty
>> and Sam are taller than Nancy. Sam is shorter than Carol. Who is the
>> shortest?
>> *
>>
>> *Update Your Answers at* : Click 
>> Here
>>
>>
>> Solution:
>> Will be updated after 1 day
>>
>>
>>
>> --
>>
>> "Never explain yourself. Your friends don’t need it
>> and your enemies won’t believe it" .
>>
>> --
>> 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.
>>
>
>
>
> --
> PIYUSH SINHA
> 9936757773
>
>  --
> 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.
>



-- 
  best wishes!!
Vaibhav Shukla
DU-MCA

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



Re: [algogeeks] [brain teaser ] WHO IS SHORTEST 12 may

2011-05-12 Thread Piyush Sinha
NANCY

On Thu, May 12, 2011 at 12:45 PM, Lavesh Rawat wrote:

>*WHO IS SHORTEST
> *
> *
> *
> **
> *Johnny is taller than Kitty and Carol. Kitty is taller than Sam. Kitty
> and Sam are taller than Nancy. Sam is shorter than Carol. Who is the
> shortest?
> *
>
> *Update Your Answers at* : Click 
> Here
>
>
> Solution:
> Will be updated after 1 day
>
>
>
> --
>
> "Never explain yourself. Your friends don’t need it and
> your enemies won’t believe it" .
>
> --
> 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.
>



-- 
PIYUSH SINHA
9936757773

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



[algogeeks] [brain teaser ] WHO IS SHORTEST 12 may

2011-05-12 Thread Lavesh Rawat
*WHO IS SHORTEST
 *
*
*
**
*Johnny is taller than Kitty and Carol. Kitty is taller than Sam. Kitty and
Sam are taller than Nancy. Sam is shorter than Carol. Who is the shortest?
*

*Update Your Answers at* : Click
Here


Solution:
Will be updated after 1 day



-- 

"Never explain yourself. Your friends don’t need it and
your enemies won’t believe it" .

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