Re: [algogeeks] Precedence or Associativity

2012-06-17 Thread rahul venkat
yea it s short circuiting 

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

2012-05-21 Thread rahul venkat
Given a string. Tell its rank among all its permutations sorted
lexicographically.

-- 
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] amazon qn

2012-05-21 Thread rahul venkat
* given a number and its permutation, how can we find out the number of
transformations by which the number could be transformed into its
permutation ?*
*
*
*eg: 2315 and 5213 are given. 2315 can be transformed into 5213 in a series
of 2 transformations. first swap 2 and 3. then swap 3 and 5.*
*
*
*suggestions will be welcome .*
*
*
*with regards,*
*rahul*

-- 
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] Re: kth largest element in two sorted arrays

2012-01-31 Thread Venkat
Hey Ashish check this link 
http://stackoverflow.com/questions/8999610/median-of-lists

Thanks and Regards,
Venkat Gottipati

On Jan 31, 10:14 am, Ashish Goel  wrote:
> i think this can be done much faster similar to findling median of two
> sorted arrays by proceeding with comparing medians of two arrays and then
> reducing the data set to approx 3/4th of 2n. I am looking for that algo if
> osmeone have.
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
>
>
>
>
> On Tue, Jan 31, 2012 at 9:26 AM, atul anand  wrote:
> > to find kth largest element in the 2 sorted array can be done by simple
> > merge...
> > obv no need for extra space...two indexes will do.
>
> > you just need to check arr1[i...n] == arr2[j..m]
>
> > if(arr1[i] > arr2[j])
> > {
> >        cnt++;
> >        index=arr2[j];
> >        j++;
>
> > }
> > else
> > {
> >      cnt++;
> >      index=arr1[i];
> >      i++;
>
> > }
>
> > if(k==cnt)
> > {
> >   print      kthe largest element is at position arr[index]
> > break;
> > }
>
> > On Tue, Jan 31, 2012 at 1:15 AM, Ashish Goel  wrote:
>
> >> Hi,
>
> >> I am trying to write code for this problem but having issues.
> >> Can you help
>
> >> 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.
>
> >  --
> > 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] hash to find repeated no

2011-12-18 Thread venkat kumar
how to use hashing to find repeated no in an array? pls give me code in c?

-- 
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] finding duplicate set of paranthesis

2011-12-10 Thread rahul venkat
hi everyone,

can u suggest an algorithm for finding the duplicate paranthesis in a given
expression ?

for example , the expression (( a + b ) * (( c + d ))) has a set of
duplicate paranthesis.

thanks in advance .

-- 
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] Re: Remove all Duplicates Words

2011-08-24 Thread Venkat
@Anup: your method wont use extra memory.

your solution is correct. But i think we can find better soultion.
Duplicate means Not only it occured 2 times, it may be 2,3 4..etc..
so we have to consider that also. In that case complexity will go like
O(N^2) ,
N= number of words in line


Thanks
Venkat.

On Aug 25, 8:45 am, ghat...@gmail.com wrote:
> @Ankur Garg: Please explain to me how my method uses extra memory?

-- 
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] Re: Find the non-duplicate element in sorted array in < O(n) time

2011-08-24 Thread Venkat
@Sanju: For your input both above solution wont work...

Do you ve any soultion for your input??
For your input Xor all numbers - will give you the result:)
but its O(n)

Anyway your input allow everyone to think little wider than Binay
search.


Thanks
Venkat


On Aug 24, 4:05 pm, Sanjay Rajpal  wrote:
> @Venkat : suppose if the array were : 1 2 2 2 2 2 2 2 2 2 2, would ur
> solution work ?
>
> Sanju
> :)
>
> On Wed, Aug 24, 2011 at 3:58 AM, Ankit Minglani 
> wrote:
>
>
>
>
>
>
>
> > How about this :
> > We use a divide and conquer approach and since the array is sorted.
> > We find the middle element and check its value with its immediate left and
> > right element .. it must match with anyone of them ..
>
> > if it doesnt we have found such a element . and otherwise we divide the
> > array again ..
> > and then again find the middle element .. to check the same condition ..
>
> > This will take O(lg n ) time :)
>
> > On Wed, Aug 24, 2011 at 3:45 PM, Venkat wrote:
>
> >>  we can solve this with the help of  binary search.
>
> >> we know N, which is odd(because of one pair missing)
>
> >> We divide it array. Let consider your input { 1,1,2,2,2,2,3,3,4,5,5}
>
> >> int find_culprit(int[] array, int start, int end)
> >> {
> >> if(end==start)
> >> return -1;
>
> >> int mid=((end-start) / 2) + start;
> >> if array[mid] == array[mid-1]
> >>      return find_culprit(mid,end)
> >> if(array[mid] == array [mid +1]
> >>      return find_culprit(start, mid);
> >> else
> >>     return array[mid];
> >> }
>
> >> Run through:
> >> Steps1: find_culprit(array,0,8)
> >> mid=4
> >> Step 2 : find_culprit(array,4,8))
> >> mid=6
> >> step 3 : find_culprit(array,6,8))
> >> mid=7
> >> return array[7]=4 (which dont have pair)
>
> >> Run time O(log n+1) = O(log n)
>
> >> Please ask if you ve any doubts.
>
> >> Regards
> >> Venkat.
>
> >> On Aug 24, 2:49 pm, atul purohit  wrote:
> >> > Hi,
>
> >> > A* sorted *integer array contains elements in pairs. All the pairs are
> >> > complete except one element whose pair is missing. Find that element.
>
> >> > Ex.   { 1,1,2,2,2,2,3,3,4,5,5}
> >> >  result = 5
>
> >> > There is a standard solution which returns an XOR of all the elements.
> >> But
> >> > this needs O(n) time complexity. The person who asked me this question
> >> said
> >> > that this can be done in < O(n). Maybe we can eliminate some elements.
> >> > Anyone knows how to do this?
>
> >> > Cheers,
> >> > Atul
>
> >> --
> >> 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.
>
> > --
> > The more you sweat in the field, the less you bleed in war."
>
> > Ankit Minglani
> > NITK Surathkal
>
> > --
> > 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] Re: Find the non-duplicate element in sorted array in < O(n) time

2011-08-24 Thread Venkat
 we can solve this with the help of  binary search.

we know N, which is odd(because of one pair missing)

We divide it array. Let consider your input { 1,1,2,2,2,2,3,3,4,5,5}

int find_culprit(int[] array, int start, int end)
{
if(end==start)
return -1;

int mid=((end-start) / 2) + start;
if array[mid] == array[mid-1]
  return find_culprit(mid,end)
if(array[mid] == array [mid +1]
  return find_culprit(start, mid);
else
 return array[mid];
}

Run through:
Steps1: find_culprit(array,0,8)
mid=4
Step 2 : find_culprit(array,4,8))
mid=6
step 3 : find_culprit(array,6,8))
mid=7
return array[7]=4 (which dont have pair)


Run time O(log n+1) = O(log n)

Please ask if you ve any doubts.

Regards
Venkat.

On Aug 24, 2:49 pm, atul purohit  wrote:
> Hi,
>
> A* sorted *integer array contains elements in pairs. All the pairs are
> complete except one element whose pair is missing. Find that element.
>
> Ex.   { 1,1,2,2,2,2,3,3,4,5,5}
>  result = 5
>
> There is a standard solution which returns an XOR of all the elements. But
> this needs O(n) time complexity. The person who asked me this question said
> that this can be done in < O(n). Maybe we can eliminate some elements.
> Anyone knows how to do this?
>
> Cheers,
> Atul

-- 
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] Re: C output

2011-08-16 Thread venkat
yes u r correct

On Aug 16, 8:22 pm, Sanjay Rajpal  wrote:
> This is becuase "Hello" is a constant string and constant strings get stored
> in *Data Area, not in stack for the function you called. *Thats why pointer
> to constant string will be returned and program will not produce any error.
>
> Sanjay Kumar
> B.Tech Final Year
> Department of Computer Engineering
> National Institute of Technology Kurukshetra
> Kurukshetra - 136119
> Haryana, India
>
> On Tue, Aug 16, 2011 at 8:19 AM, rohit  wrote:
> > #includeconst char *fun();
> > int main()
> > {
> >     char *ptr = fun();
> >     return 0;
> > }const char *fun()
> > {
> >     return "Hello";
> > }
>
> > Why doesn't this code give error??
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/algogeeks/-/qeUTNwGNKfwJ.
> > 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] Re: Closest ancestor of two nodes

2011-08-09 Thread Venkat
Don solution is perfect.
i double checked it..

On Aug 9, 9:01 pm, Don  wrote:
> tree closestSharedAncestor(tree root, tree node1, tree node2, int
> &result)
> {
>   tree returnValue = 0;
>
>   if (root)
>   {
>     if (root == node1) result += 1;
>     if (root == node2) result += 2;
>     int sum = 0;
>     tree returnLeft = closestSharedAncestor(root->left, node1, node2,
> sum);
>     if (returnLeft) returnValuet = returnLeft;
>     else
>     {
>       tree returnRight = closestSharedAncestor(root->right, node1,
> node2, sum);
>       if (returnRight) returnValue = returnRight;
>       else if (sum == 3) returnValue = root;
>     }
>     result += sum;
>   }
>   return returnValue;
>
> }
>
> On Aug 9, 9:56 am, Raman  wrote:
>
>
>
> > Can anyone give me the recursive algo to find closest ancestor of two nodes
> > in a tree(not a BST).- Hide quoted text -
>
> - Show quoted text -

-- 
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] Re: recursive nearest square

2011-08-07 Thread Venkat
Find_Nearest(i , prev , n)
{
int sqr=n*n;
if(sqr > i)
  {
  if((sqr-i)>(i-prev))
return sqr ;
  else
return prev;
  }
  Find_Nearest(i,sqr,n+1);


}


initial call value : Find_Nearest(27, 0, 1);
prev= previous square value.

Thanks
Venkat
http://cloud-computation.blogspot.com/




On Aug 7, 7:41 pm, Nikhil Veliath  wrote:
> write a recursive code to print the nearest square of a number
>
> eg if no is 27
>
> the nearest square is 5
>
> it should also take care of large nos...

-- 
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] Re: Amazon Puzzle

2011-08-07 Thread Venkat
I ve a small assumption, if we consider flight go in straight
direction.

Then in one paper, they can write " Walk towards flight direction" and
jump first.

In another paper "Walk towards opposite to flight direction."
and jump jump at any random location in that stright line..
then they can meet at middle point.

Its may be a soultion, but not sure.

Thanks
Venkat
http://cloud-computation.blogspot.com/

On Aug 7, 10:59 pm, Algo Lover  wrote:
> Two people are travelling through flight. Both have parachute and jump
> anywhere randomly i.e none of them knows who has jumped where.(Assume
> there's a big desert and they jump at any random location). Now, both
> of them have a single piece of paper on which they can write
> instructions before jumping and that's the only way they can meet each
> other. What would they write on paper before jumping ?

-- 
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] Re: recursion nearest square

2011-08-07 Thread Venkat
Find_Nearest(i , prev , n)
{
int sqr=n*n;
if(sqr > i)
  {
  if((sqr-i)>(i-prev))
return sqr ;
  else
return prev;
  }
  Find_Nearest(i,sqr,n+1);
}

initial call value : Find_Nearest(27, 0, 1);
prev= previous square value.

Thanks
Venkat
http://cloud-computation.blogspot.com/


On Aug 7, 7:39 pm, Nikhil Veliath  wrote:
> write a recursive code to print the nearest square of a number
>
> eg if no is 27
>
> the nearest square is 5
>
> it should also take care of large nos...

-- 
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] Binary Tree Problem

2011-06-05 Thread venkat kumar
check for a*&ao*,even tough they are search heuristics, some modification of
the algorithm would solve the problem.

On Mon, May 30, 2011 at 12:56 AM, ross  wrote:

> Given a binary tree(not a BST) find the 2 nodes of the binary tree
> which are separated by maximum distance.
>  By distance, we mean no. of edges in the path from node1 to node2.
>
> --
> 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] Amazon online test

2011-06-05 Thread venkat kumar
@balaji a

can u specify the basic criteria,ie,min.cgpa,required for amazon on campus
recruitment, also interview procedure?

On Thu, May 26, 2011 at 11:27 PM, balaji a  wrote:

> I actually attended on-campus through my college...
>
> On 26 May 2011 16:24, "jagannath prasad das"  wrote:
>
> how to register for amazon ol exm .can  you plz mention ?
>
> On Sun, Apr 24, 2011 at 6:46 PM, balaji a  wrote:
>
>> >
>> > yeah i did.,...there were two section
>> > Section 1 - some aptitude question + predicting output ...
>>
>>  --
>>
>> > You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" gr...
>
>  --
> 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] number distribution algo

2011-05-20 Thread venkat kumar
Given a set of numbers,how to find whether it is uniformly distributed?

-- 
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-03 Thread venkat kumar
sir,
 kindly send me the link too.
 thank you

On Fri, Apr 29, 2011 at 9:35 PM, Umer Farooq  wrote:

> please send it to me at "the.um...@gmail.com"
>
> Thanks in advance :)
>
>
> On Sat, Apr 30, 2011 at 8:41 AM, Manish Kumar 
> wrote:
>
>> please send me this book to my email , thanks" manish.iitia...@gmail.com'
>>
>>
>>
>> On Sat, Apr 30, 2011 at 6:07 AM, Venkat  wrote:
>>
>>> Hey how's ur interview?
>>> if u have the book pls mail me to " gvr.su...@gmail.com "
>>>
>>> On Apr 19, 6:19 am, nagajyothi gunti 
>>> wrote:
>>> > Please send me too at nagajyothi.gu...@gmail.com
>>> > Also, please let me know what all to prepare...I have an phone
>>> interview
>>> > from amazon this wednesday.
>>> >
>>> > On Mon, Apr 18, 2011 at 2:40 PM, vaibhav agrawal >> >wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > Please send it to me tooo agrvaib...@gmail.com
>>> >
>>> > > On Mon, Apr 18, 2011 at 10:30 PM, Rel Guzman Apaza <
>>> rgap...@gmail.com>wrote:
>>> >
>>> > >> Send to me too. Please. rgap...@gmail.com
>>> >
>>> > >> 2011/4/18 Abhishek Goswami 
>>> >
>>> > >>> I think we can share into email...that will not be any
>>> issue. :)
>>> >
>>> > >>> On Mon, Apr 18, 2011 at 10:07 PM, Abhishek Goswami <
>>> > >>> zeal.gosw...@gmail.com> wrote:
>>> >
>>> > >>>> can u please me also .. zeal_gosw...@yahoo.com
>>> >
>>> > >>>> On Thu, Apr 14, 2011 at 11:50 AM, Himanshu Neema <
>>> > >>>> potential.himansh...@gmail.com> wrote:
>>> >
>>> > >>>>> Hi All ,
>>> > >>>>> Yesterday I received an email from Author that this is *violation
>>> of
>>> > >>>>> Intellectual Property Ownership* ,So kindly please delete pdfs &
>>> > >>>>> please remove all the sharing.
>>> >
>>> > >>>>> Thanks Guys.
>>> > >>>>> Himanshu
>>> >
>>> > >>>>> On Thu, Apr 14, 2011 at 10:52 AM, Harshal 
>>> wrote:
>>> >
>>> > >>>>>> Thanks :)
>>> >
>>> > >>>>>> On Thu, Apr 14, 2011 at 9:59 AM, Rajeev Kumar <
>>> > >>>>>> rajeevprasa...@gmail.com> wrote:
>>> >
>>> > >>>>>>> check this link:
>>> >
>>> > >>>>>>>
>>> https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=1B5...
>>> >
>>> > >>>>>>> If you have any problem in access,please inform
>>> me
>>> >
>>> > >>>>>>> On Thu, Apr 14, 2011 at 1:04 AM, Abhishek Goswami <
>>> > >>>>>>> zeal.gosw...@gmail.com> wrote:
>>> >
>>> > >>>>>>>> Hi,
>>> > >>>>>>>> I tried to open this book in google docs and got message that
>>> file
>>> > >>>>>>>> is not avaliable. does this file not available in google docs
>>> > >>>>>>>> if yes , can anybody share this book again
>>> >
>>> > >>>>>>>> On Tue, Mar 22, 2011 at 10:41 PM, Himanshu Neema <
>>> > >>>>>>>> potential.himansh...@gmail.com> wrote:
>>> >
>>> > >>>>>>>>> Turns out that I cant send file larger than 4 MB , please
>>> download
>>> > >>>>>>>>> it from here , let me know if you're still unable to
>>> download:
>>> >
>>> > >>>>>>>>>
>>> http://dl.dropbox.com/u/2681370/Algorithms%2Bfor%2BInterviews%2B%28sc...
>>> >
>>> > >>>>>>>>> have fun !
>>> >
>>> > >>>>>>>>> On Tue, Mar 22, 2011 at 10:21 PM, Himanshu Neema <
>>> > >>>>>>>>> potential.himansh...@gmail.com> wrote:
>>> >
>>> > >>>&

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

2011-04-29 Thread Venkat
Hey how's ur interview?
if u have the book pls mail me to " gvr.su...@gmail.com "

On Apr 19, 6:19 am, nagajyothi gunti 
wrote:
> Please send me too at nagajyothi.gu...@gmail.com
> Also, please let me know what all to prepare...I have an phone interview
> from amazon this wednesday.
>
> On Mon, Apr 18, 2011 at 2:40 PM, vaibhav agrawal wrote:
>
>
>
>
>
>
>
>
>
> > Please send it to me tooo agrvaib...@gmail.com
>
> > On Mon, Apr 18, 2011 at 10:30 PM, Rel Guzman Apaza wrote:
>
> >> Send to me too. Please. rgap...@gmail.com
>
> >> 2011/4/18 Abhishek Goswami 
>
> >>> I think we can share into email...that will not be any issue. :)
>
> >>> On Mon, Apr 18, 2011 at 10:07 PM, Abhishek Goswami <
> >>> zeal.gosw...@gmail.com> wrote:
>
>  can u please me also .. zeal_gosw...@yahoo.com
>
>  On Thu, Apr 14, 2011 at 11:50 AM, Himanshu Neema <
>  potential.himansh...@gmail.com> wrote:
>
> > Hi All ,
> > Yesterday I received an email from Author that this is *violation of
> > Intellectual Property Ownership* ,So kindly please delete pdfs &
> > please remove all the sharing.
>
> > Thanks Guys.
> > Himanshu
>
> > On Thu, Apr 14, 2011 at 10:52 AM, Harshal  wrote:
>
> >> Thanks :)
>
> >> On Thu, Apr 14, 2011 at 9:59 AM, Rajeev Kumar <
> >> rajeevprasa...@gmail.com> wrote:
>
> >>> check this link:
>
> >>>https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=1B5...
>
> >>> If you have any problem in access,please inform me
>
> >>> On Thu, Apr 14, 2011 at 1:04 AM, Abhishek Goswami <
> >>> zeal.gosw...@gmail.com> wrote:
>
>  Hi,
>  I tried to open this book in google docs and got message that file
>  is not avaliable. does this file not available in google docs
>  if yes , can anybody share this book again
>
>  On Tue, Mar 22, 2011 at 10:41 PM, Himanshu Neema <
>  potential.himansh...@gmail.com> wrote:
>
> > Turns out that I cant send file larger than 4 MB , please download
> > it from here , let me know if you're still unable to download:
>
> >http://dl.dropbox.com/u/2681370/Algorithms%2Bfor%2BInterviews%2B%28sc...
>
> > have fun !
>
> > On Tue, Mar 22, 2011 at 10:21 PM, Himanshu Neema <
> > potential.himansh...@gmail.com> wrote:
>
> >> Enjoy :)
>
> >> On Tue, Mar 22, 2011 at 10:09 PM, Saravanan T <
> >> mail2sarava...@gmail.com> wrote:
>
> >>> ++
>
> >>> On Tue, Mar 22, 2011 at 9:51 PM, Anurag atri <
> >>> anu.anurag@gmail.com> wrote:
>
>  and me too :)
>
>  On Tue, Mar 22, 2011 at 9:28 PM, Nikhil Mishra <
>  mishra00...@gmail.com> wrote:
>
> > count me too
>
> > On Tue, Mar 22, 2011 at 11:16 AM, kunal srivastav <
> > kunal.shrivas...@gmail.com> wrote:
>
> >> plz send it to me too
>
> >> On Tue, Mar 22, 2011 at 11:14 AM, D.N.Vishwakarma@IITR <
> >> deok...@gmail.com> wrote:
>
> >>> --
>
> >>> *With Regards
> >>> Deoki Nandan Vishwakarma
> >>> IITR MCA
> >>> Mathematics Department
> >>> *
>
> >>> --
> >>> 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.
>
> >> --
> >> thezeitgeistmovement.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.
>
> >  --
> > 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
>  Anurag Atri
>
>  --
>  You received this message because you are subscribed to the
>  Google Groups "Alg

[algogeeks] solutions?

2010-07-11 Thread venkat kumar
are solutions available for problems in
spoj,uva,codedhef,topcoder,etc.etc.?pls tell me
tnkyou

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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: A nice Prob

2010-07-02 Thread venkat kumar
 what is the website having collection of ms questions?


On Thu, Jul 1, 2010 at 6:48 PM, vicky  wrote:

> Actually i saw a forum of MS questions and same as i wrote was written
> there. I too was confused but finally came to conclusion as u.
> Anyways
>
> On Jul 1, 5:51 pm, Gene  wrote:
> > On Jul 1, 6:46 am, vicky  wrote:
> >
> > > It took me more time to understand this problem then solving after i
> > > understood.
> > > You guys too have a look @ it.::
> > > Let f(k) = y where k is the y-th number in the increasing sequence of
> > > non-negative
> > > integers with the same number of ones in its binary representation as
> > > y, e.g. f(0) = 1, f(1) => 1, f(2) = 2, f(3) = 1, f(4) = 3, f(5) = 2,
> f(6) = 3
> > > and so on.
> > > Given k >= 0, compute f(k).
> >
> > There must be a mistake in you problem statement or examples.  It only
> > makes sense if you change it as follows:
> >
> > Let f(k) = y where k is the y-th number in the increasing sequence of
> > non-negative integers with the same number of ones in its
> > binary representation as k, <<-- change this from y to k.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@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 algoge...@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] single source problem

2010-06-27 Thread venkat kumar
in single source shortest path ,having neg cost edges is good but:

  1)it may
lead us goto into a loop of arbitrary time
in the meanwhile we can have another path with minimum  positive cost but
with less time.
now by taking time factor into consideration,ie,larger path with neg cost or
smaller path with larger cost
 how to code this??

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] data structure and algorithm implementation

2010-05-21 Thread venkat kumar
i'm new to coding.it is  difficult to implement algorithms and even standard
data structures is there a sort of lab manual available and are there
solutions to problems in uva,sphere etc etc websites kindly reply.
thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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] Online Math Coding Contest

2010-01-05 Thread kannan venkat
Hi , we gladly invite you to take part in Athena - the Online Math Coding
Contest of Kurukshetra 2010 , the International Techo-Management Fest
organised by College  Of Engineering Guindy , India organised under the
patronage of UNESCO .

Here's your chance to lock horns against the best minds across the globe and
showcase your algorithmic prowess and mathematical acumen !!
Participants from 20+  countries already registered!!

catch the action at  www.athena.kurukshetra.org.in   Exciting prizes to
be won !!

Dates :
Practice contest  : 6th January 5.00 P.M Indian Standard Time
Main  contest  : 8th January - 15th January

awaiting your presence ,
Team Athena
-- 

You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.

To post to this group, send email to algoge...@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] Re:

2009-08-15 Thread santhosh venkat
The reply posted above suggesting Grundy numbers is most efficient than the
game tree given there in wikipedia.I think game tree has exponential run
time for this egg problem. It can be applied to tic-tac toe game
successfully as there are 9 places to be used . but here each basket may
have any number of eggs
On Sat, Aug 15, 2009 at 8:51 PM, sharad kumar wrote:

>
> can u use a game tree
> http://en.wikipedia.org/wiki/Game_tree
>
> On Sat, Aug 15, 2009 at 8:49 PM, santhosh venkat <
> santhoshvenkat1...@gmail.com> wrote:
>
>> @ Sharad
>>  I think the replier's logic and explanation for the same can be found
>> here .
>>  http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=algorithmGames
>> Besides i think dp can also be applied here .but it needs lot of memory
>>  Santhosh .
>>
>>
>> On Sat, Aug 15, 2009 at 8:42 PM, sharad kumar wrote:
>>
>>> pls explain a bit.suppose there aare 2 baskets and lets assume 12
>>> eggs in basket 1 and 15 in b2.wat will u do
>>>
>>>
>>> On Sat, Aug 15, 2009 at 8:33 PM, Arun N  wrote:
>>>
>>>> this is same as NIM
>>>> the concept is Grundy Numbers
>>>> just xor all the numbers
>>>> if it is zero 1st player will lose
>>>> else 1st player will win
>>>> assuming both play optimally
>>>>
>>>> Arun,
>>>>
>>>> On Fri, Aug 14, 2009 at 7:50 PM, sharad kumar 
>>>> wrote:
>>>>
>>>>> both
>>>>>
>>>>> On Fri, Aug 14, 2009 at 7:35 PM, ganesa thandavam <
>>>>> gthanda...@gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> is the number of eggs same in all baskets ???
>>>>>>
>>>>>> On Aug 14, 7:00 pm, sharad kumar  wrote:
>>>>>> > There are N egg baskets and the number of eggs in each basket is a
>>>>>> known
>>>>>> > quantity. Two players take turns to remove these eggs from the
>>>>>> baskets. On
>>>>>> > each turn, a player must remove at least one egg, and may remove any
>>>>>> number
>>>>>> > of eggs provided they all belong to the same basket. The player
>>>>>> picking the
>>>>>> > last egg(s) wins the game. If you are allowed to decide who is going
>>>>>> to
>>>>>> > start first, what mathematical function would you use to decide so
>>>>>> that you
>>>>>> > end up on the winning side?
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Potential is not what U have, its what U think U have!!!
>>>> It is better to worn out than rust.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

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



[algogeeks] Re:

2009-08-15 Thread santhosh venkat
@ Sharad
 I think the replier's logic and explanation for the same can be found here
.
 http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=algorithmGames
Besides i think dp can also be applied here .but it needs lot of memory
 Santhosh .

On Sat, Aug 15, 2009 at 8:42 PM, sharad kumar wrote:

> pls explain a bit.suppose there aare 2 baskets and lets assume 12 eggs
> in basket 1 and 15 in b2.wat will u do
>
>
> On Sat, Aug 15, 2009 at 8:33 PM, Arun N  wrote:
>
>> this is same as NIM
>> the concept is Grundy Numbers
>> just xor all the numbers
>> if it is zero 1st player will lose
>> else 1st player will win
>> assuming both play optimally
>>
>> Arun,
>>
>> On Fri, Aug 14, 2009 at 7:50 PM, sharad kumar wrote:
>>
>>> both
>>>
>>> On Fri, Aug 14, 2009 at 7:35 PM, ganesa thandavam 
>>> wrote:
>>>

 is the number of eggs same in all baskets ???

 On Aug 14, 7:00 pm, sharad kumar  wrote:
 > There are N egg baskets and the number of eggs in each basket is a
 known
 > quantity. Two players take turns to remove these eggs from the
 baskets. On
 > each turn, a player must remove at least one egg, and may remove any
 number
 > of eggs provided they all belong to the same basket. The player
 picking the
 > last egg(s) wins the game. If you are allowed to decide who is going
 to
 > start first, what mathematical function would you use to decide so
 that you
 > end up on the winning side?



>>>
>>>
>>>
>>
>>
>> --
>> Potential is not what U have, its what U think U have!!!
>> It is better to worn out than rust.
>>
>>
>>
>>
>>
>
> >
>

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



[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread santhosh venkat
 i think itoa  wont work for long long type and as far i know it is designed
to work only for integers only... so u cant find remainder for longer
numbers with the logic  u said above
On Fri, Aug 14, 2009 at 7:36 PM, sharad kumar wrote:

> say withou itoa yaar.
>
>
> On Fri, Aug 14, 2009 at 7:35 PM, Yogesh Aggarwal <
> yogesh.aggarwa...@gmail.com> wrote:
>
>> u can use the itoa function for that...
>>
>>
>> On Fri, Aug 14, 2009 at 7:31 PM, sharad kumar wrote:
>>
>>> brother how do u get the digits of number ???u use % and / rite??
>>>
>>>
>>>  On Fri, Aug 14, 2009 at 7:28 PM, Yogesh Aggarwal <
>>> yogesh.aggarwa...@gmail.com> wrote:
>>>
>>>> (CORRECTED ALGO.)
>>>>  We can do like dis...
>>>> - add all d digits of the no.
>>>> - if the result is MORE than 10, add all the digits of the result again.
>>>> - continue step2 if the result is still MORE than 10
>>>> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>>>>
>>>> example 1 :
>>>> num = 12345
>>>> sum1 = 15 (sum > 10)
>>>> sum2 = 6
>>>> since sum < 10, we stop here and since final sum = 6 so the given
>>>> no. is divisible by 3
>>>>
>>>>
>>>> On Fri, Aug 14, 2009 at 7:25 PM, Yogesh Aggarwal <
>>>> yogesh.aggarwa...@gmail.com> wrote:
>>>>
>>>>> (CORRECTED ALGO.)
>>>>> We can do like dis...
>>>>> - add all d digits of the no.
>>>>> - if the result is MORE than 10, add all the digits of the result
>>>>> again.
>>>>> - continue step2 if the result is still less than 10
>>>>> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>>>>>
>>>>> example 1 :
>>>>> num = 12345
>>>>> sum1 = 15 (sum > 10)
>>>>> sum2 = 6
>>>>> since sum < 10, we stop here and since final sum = 6 so the given
>>>>> no. is divisible by 3
>>>>>
>>>>> On Fri, Aug 14, 2009 at 7:20 PM, santhosh venkat <
>>>>> santhoshvenkat1...@gmail.com> wrote:
>>>>>
>>>>>> given a number n
>>>>>>  u can get the quotient when it is divided by 4 using right shift 2
>>>>>> times
>>>>>> like n >> 2 this ll give u quotient(q)
>>>>>> u can get the remainder by subtracting 4 * q from n which will give
>>>>>> the remainder when divided by 4
>>>>>>
>>>>>> by doing this u ll express n as n = 4q + r  = 3q + (q+r)
>>>>>> in this already 3q which is divisible by 3 .. u can apply the same
>>>>>> logic recursively to q+r and return the remainder obtained for q+r..
>>>>>>
>>>>>>
>>>>>> On Fri, Aug 14, 2009 at 7:11 PM, Yogesh Aggarwal <
>>>>>> yogesh.aggarwa...@gmail.com> wrote:
>>>>>>
>>>>>>> @arun : we are not supposed to use / operator. but in ur algo u r
>>>>>>> using / or %  has to be used to check wether the diff is divisible by 3.
>>>>>>> We can do like dis...
>>>>>>> - add all d digits of the no.
>>>>>>> - if the result is less than 10, add all the digits of the result
>>>>>>> again.
>>>>>>> - continue step2 if the result is still less than 10
>>>>>>> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by
>>>>>>> 3.
>>>>>>>
>>>>>>> example 1 :
>>>>>>> num = 12345
>>>>>>> sum1 = 15 (sum > 10)
>>>>>>> sum2 = 6
>>>>>>> since sum < 10, we stop here and since final sum = 6 so the given
>>>>>>> no. is divisible by 3
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Aug 14, 2009 at 3:09 PM, Arun N  wrote:
>>>>>>>
>>>>>>>> take an number find its binary
>>>>>>>> add all odd bits and even bits seperately
>>>>>>>> now check if the difference is divisible by 3
>>>>>>>> if yes it is
>>>>>>>> say 6 110  ->  1+0 - 1 =0
>>>>>>>> 9 1001 -> 1+0 - 0+1 = 0
>>>>>>>> 12 1100  --> 1+0 - 1+0  =

[algogeeks] Re: Check divisibility by 3

2009-08-14 Thread santhosh venkat
given a number n
 u can get the quotient when it is divided by 4 using right shift 2 times
like n >> 2 this ll give u quotient(q)
u can get the remainder by subtracting 4 * q from n which will give  the
remainder when divided by 4

by doing this u ll express n as n = 4q + r  = 3q + (q+r)
in this already 3q which is divisible by 3 .. u can apply the same logic
recursively to q+r and return the remainder obtained for q+r..


On Fri, Aug 14, 2009 at 7:11 PM, Yogesh Aggarwal <
yogesh.aggarwa...@gmail.com> wrote:

> @arun : we are not supposed to use / operator. but in ur algo u r using /
> or %  has to be used to check wether the diff is divisible by 3.
> We can do like dis...
> - add all d digits of the no.
> - if the result is less than 10, add all the digits of the result again.
> - continue step2 if the result is still less than 10
> - if the result is either 0, 3 , 6 or 9 den the no. is divisible by 3.
>
> example 1 :
> num = 12345
> sum1 = 15 (sum > 10)
> sum2 = 6
> since sum < 10, we stop here and since final sum = 6 so the given no.
> is divisible by 3
>
>
> On Fri, Aug 14, 2009 at 3:09 PM, Arun N  wrote:
>
>> take an number find its binary
>> add all odd bits and even bits seperately
>> now check if the difference is divisible by 3
>> if yes it is
>> say 6 110  ->  1+0 - 1 =0
>> 9 1001 -> 1+0 - 0+1 = 0
>> 12 1100  --> 1+0 - 1+0  = 0
>> Arun,
>>
>> On Fri, Aug 14, 2009 at 1:15 PM, richa gupta wrote:
>>
>>>
>>> can we check the divisibility of a given number by 3 withoutusing
>>> operators like '/' or '%'.
>>> I want the efficient solution to this problem ..
>>>
>>> can someone help ??
>>> --
>>> Richa Gupta
>>> (IT-BHU,India)
>>>
>>>
>>>
>>
>>
>> --
>> Potential is not what U have, its what U think U have!!!
>> It is better to worn out than rust.
>>
>>
>>
>>
>>
>
>
> --
> Best Wishes & Regards
> Thank You
> Yogesh Aggarwal
> B.Tech(IT),
> University School of Information Technology
> GGS Indraprastha University
> Delhi
> mailto: yogesh.aggarwa...@gmail.com
> #9990956582
>
> >
>

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



[algogeeks] Re: Finding repeated element in most efficient way

2009-08-09 Thread santhosh venkat
http://en.wikipedia.org/wiki/Pigeonhole_sortI
think it was the repliers intention. But i think it is not the most optimal
way of solving the question as the amount of memory it needs in the worst
case is higher

On Sun, Aug 9, 2009 at 1:47 PM, richa gupta  wrote:

> what is this pigeonhole sort ??
>
> 2009/8/9 sharad kumar 
>
> use pigeonhole sort
>>
>>
>> On Sun, Aug 9, 2009 at 12:47 PM, richa gupta wrote:
>>
>>> Hi,
>>> An array consists of all unique integers but one. The repeated element
>>> repeats in the order of two i.e. the repeated integer is 2, 4, 8, 16,
>>> etc times in the array.
>>> How to find the repeated element in most efficient way?
>>>
>>> --
>>> Richa Gupta
>>> (IT-BHU,India)
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> Richa Gupta
> (IT-BHU,India)
>
> >
>

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



[algogeeks] Re: Lucky numbers

2009-01-06 Thread Vijay Venkat Raghavan N
Oops. I mis-read the problem!! I didn't realized numbers are being knocked
off the list in every iteration, I somehow thought that the struck out
numbers retain their position. Sorry about the confusion!!!

On Tue, Jan 6, 2009 at 11:16 AM, Pratyush Tewari
wrote:

>
> No... lucky numbers can be composite also ... see this output
> 35
> 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
> 21  22  23  24  25
> 26  27  28  29  30  31  32  33  34  35
> Deleting every number 2 from above.
> 1  3  5  7  9  11  13  15  17  19  21  23  25  27  29  31  33  35
> Deleting every number 3 from above.
> 1  3  7  9  13  15  19  21  25  27  31  33
> Deleting every number 4 from above.
> 1  3  7  13  15  19  25  27  31
> Deleting every number 5 from above.
> 1  3  7  13  19  25  27  31
> Deleting every number 6 from above.
> 1  3  7  13  19  27  31
> Deleting every number 7 from above.
> 1  3  7  13  19  27
>
> 27 is not prime and a lucky number. So the method is fine.
>
> Pratyush Tewari
>
>
>
> On Mon, Jan 5, 2009 at 12:30 AM, Vijay Venkat Raghavan N
>  wrote:
> > Guys this is wrong. Lucky number is basically a prime number if you
> observe
> > the definition carefully, and this approach of determining primality
> > obviously won't work.
> >
> > On Sun, Jan 4, 2009 at 7:12 PM, Channa Bankapur <
> channabanka...@gmail.com>
> > wrote:
> >>
> >> Here is the C-version of the same. It tells you whether given n is lucky
> >> or not.
> >> void luckyOrNot(long int n){
> >>
> >> long int n2 = n;
> >> int i= 2;
> >> while(n2>=i){
> >>
> >> if(n2%i == 0){
> >>
> >> printf("%ld got unlucky when i was %d\n", n, i);
> >> break;
> >>
> >> }
> >> n2 = n2 - (n2/i);
> >> i++;
> >>
> >> }
> >> if(n2 >> printf("%ld is lucky\n", n);
> >> }
> >>
> >> }
> >>
> >> Cheers,
> >> Channa
> >> On Sun, Jan 4, 2009 at 10:34 AM, Sathya Narayanan
> >>  wrote:
> >> > first n will be the nth number in the sequence.. after each iteration
> >> > (intially i=2) the new position of n is calculated as n=n- (n/i) and
> if
> >> > n%i
> >> > then u stop.. this goes on until n then
> >> > n is
> >> > lucky.. this is the approach used in tht perl prog i guess
> >> >
> >> >
> >> > 2009/1/4 daizi sheng 
> >> >>
> >> >> check this perl program, hope it explains the algorithm itself
> >> >>
> >> >> >>>>>>START OF algo.pl<<<<<<<<<<<<
> >> >> use warnings;
> >> >> use strict;
> >> >>
> >> >> sub is_lucky_number
> >> >> {
> >> >>my ($cur, $n, $last_n, $next_n, $old_n);
> >> >>
> >> >>$cur = 1; # to remove numbers at $cur, $cur*2, ...
> >> >>$n = shift @_; # current index of the input number before removing
> >> >>$old_n = $n;
> >> >>
> >> >>die unless $n > 0;
> >> >>$last_n = -1; # index of the input number when after removing
> >> >> every $cur-1 number
> >> >>
> >> >>while($last_n != $n)
> >> >>{
> >> >>$cur++;
> >> >>$next_n = $n - int($n / $cur);
> >> >>if($n % $cur == 0)
> >> >>{
> >> >>#print "$old_n is removed at $cur-th step\n";
> >> >>return 0; # input number is not lucky because it will be
> >> >> removed at $cur-th step
> >> >>}
> >> >>$last_n = $n;
> >> >>$n = $next_n;
> >> >>}
> >> >>
> >> >>return 1;
> >> >> }
> >> >>
> >> >> foreach my $input (1..100)
> >> >> {
> >> >>print "$input is lucky\n" if &is_lucky_number($input);
> >> >> }
> >> >>
> >> >> print "Press return to exit\n";
> >> >> <>;
> >> >>
> >> >>
> >> >>
> >> >> On Sun, Jan 4, 2009 at 2:08 AM, kannan  wrote:
> >> >> >
> >> >> > All the numbers from 1 to infinity are written in sequence:
> >> >> >

[algogeeks] Re: Lucky numbers

2009-01-05 Thread Vijay Venkat Raghavan N
Guys this is wrong. Lucky number is basically a prime number if you observe
the definition carefully, and this approach of determining primality
obviously won't work.

On Sun, Jan 4, 2009 at 7:12 PM, Channa Bankapur wrote:

> Here is the C-version of the same. It tells you whether given n is lucky or
> not.
> void luckyOrNot(long int n){
>
> long int n2 = n;
> int i= 2;
> while(n2>=i){
>
> if(n2%i == 0){
>
>  printf("%ld got unlucky when i was %d\n", n, i);
> break;
>
> }
> n2 = n2 - (n2/i);
> i++;
>
> }
> if(n2 printf("%ld is lucky\n", n);
> }
>
> }
>
> Cheers,
> Channa
>
> On Sun, Jan 4, 2009 at 10:34 AM, Sathya Narayanan <
> sathya.phoe...@gmail.com> wrote:
> > first n will be the nth number in the sequence.. after each iteration
> > (intially i=2) the new position of n is calculated as n=n- (n/i) and if
> n%i
> > then u stop.. this goes on until n is
> > lucky.. this is the approach used in tht perl prog i guess
> >
> >
> > 2009/1/4 daizi sheng 
> >>
> >> check this perl program, hope it explains the algorithm itself
> >>
> >> >>START OF algo.pl
> >> use warnings;
> >> use strict;
> >>
> >> sub is_lucky_number
> >> {
> >>my ($cur, $n, $last_n, $next_n, $old_n);
> >>
> >>$cur = 1; # to remove numbers at $cur, $cur*2, ...
> >>$n = shift @_; # current index of the input number before removing
> >>$old_n = $n;
> >>
> >>die unless $n > 0;
> >>$last_n = -1; # index of the input number when after removing
> >> every $cur-1 number
> >>
> >>while($last_n != $n)
> >>{
> >>$cur++;
> >>$next_n = $n - int($n / $cur);
> >>if($n % $cur == 0)
> >>{
> >>#print "$old_n is removed at $cur-th step\n";
> >>return 0; # input number is not lucky because it will be
> >> removed at $cur-th step
> >>}
> >>$last_n = $n;
> >>$n = $next_n;
> >>}
> >>
> >>return 1;
> >> }
> >>
> >> foreach my $input (1..100)
> >> {
> >>print "$input is lucky\n" if &is_lucky_number($input);
> >> }
> >>
> >> print "Press return to exit\n";
> >> <>;
> >>
> >>
> >>
> >> On Sun, Jan 4, 2009 at 2:08 AM, kannan  wrote:
> >> >
> >> > All the numbers from 1 to infinity are written in sequence:
> >> >
> >> > 1,2,3,4,5,6,7,8,9,10,11,12,13,14.
> >> > in the first iteration, every second number is removed, leaving:
> >> > 1,3,5,7,9,11,13
> >> > in the second iteration, every third number in the above sequence is
> >> > removed, thus leaving: 1,3,7,9,13
> >> > in the third iteration, every fourth number is removed, leaving:
> >> > 1,3,7,13
> >> > like this the process goes on indefinitely.
> >> > the numbers which are, thus, left are called lucky numbers.
> >> >
> >> > Given a number n(can be as big as 18 digits) you must tell if n is a
> >> > lucky number or not.. how do i proceed?? all that i can think of is a
> >> > naive implementation which obviously wont work because n can be as big
> >> > as 18 digits...
> >> > could you help me or give suggestions on how to proceed
> >> > (This question was asked in a practice contest which is over now)
> >> >
> >> > >
> >> >
> >>
> >>
> >
> >
> >
>
> >
>


-- 
"Success as an entrepreneur is absolute, everything else is relative"

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



[algogeeks] Re: DataStructure - Push,Pop & Find_Min in O(1)

2006-03-25 Thread Vijay Venkat Raghavan N
extract_min not possible cos that wud been a brand new sorting algorithms that runs in O(n) time.On 3/25/06, Balaji Gopalan <
[EMAIL PROTECTED]> wrote:hithe extension of this prob asks
whether one more function extract_min() (which returns and deletes the
current minimum ) can be  implemented in O(1) time.[hint: it cant be...y?]balaji 

On 3/25/06, ridvansg <[EMAIL PROTECTED]> wrote:






--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/algogeeks  -~--~~~~--~~--~--~---


[algogeeks] Re: determine whether a matrix is rearrangeable

2006-03-17 Thread Vijay Venkat Raghavan N
hi,

well am not really sure about this stuff, but i guess if theres a 1 in
each row and each coloum initially, then it is rearrangeable. i am not
able to think of a rigorous proof as of now.

-VijayOn 3/18/06, kool_guy <[EMAIL PROTECTED]> wrote:
Let A be a "n by n" matrix.  A is rearrangeable if there is a way toswap rows with rows, and columns with columns, such that after theswapping, all diagonal entries of A are equal to 1.Can someone give an algorithm that determines whether a matrix is


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/algogeeks  -~--~~~~--~~--~--~---


[algogeeks] Re: Finding duplicate

2005-12-20 Thread Vijay Venkat Raghavan N
Hi,

First of all to adak. This problem cannot use your logic as even if the
range is from 1 to 65000, as you have given for example, i can easily
pick put 4 numbers like 1,10,456,65000. The Complexity of your algo is
65000, mine wud be 4lg4 = 8.

Pramod: Great point man, even I thought it had to be nlgn, but well, I am not sure now.

-VijayOn 12/8/05, Dhyanesh <[EMAIL PROTECTED]> wrote:
Hashing has collisions. What if all the numbers hash to the same
position (in the worst case)? Then you will be back to square one.
Hashing is just a hack for any problem ... not a proper solution.

-Dhyanesh
On 12/8/05, mathmoi <[EMAIL PROTECTED]
> wrote:
Dhyanesh wrote:> I agree it is faster but you cannot use it will all inputs. I gave you a> test case and you still havent come out on how to solve that. Your algorithm> is limited to a range of numbers only. It will be very slow even for numbers
> like 2^31 or so which fit into the size of an integer (and you can run it> only if you have 2GB virtual memory). Give it such inputs and you will it> will perform much much worse than doing the nlgn algorithm. One more thing
> how are you going to handle -ve numbers.>> Tell me how fast it is with this set ... { - 2^30, -23, 64,1 ,4,1 , 2^31 }> ... try  make it run faster than nlogn sorting.What if he use a hash table instead of an array? The hash table only
need to be a little bit bigger than to original array and could usevery big (or even negative) index.Mathieu Pagé




[algogeeks] Re: Given N numbers & z value , find x, y such that x + y = z

2005-12-20 Thread Vijay Venkat Raghavan N
Hi Hemanth,

It would be nice if you can come up with an O(n) algorithm for that,
but frankly, I dont think it is possible at all. Of course, if the
numbers are all in O(n) and if we can afford O(n) additional space, we
can go in for a counting sort like mechanism. Or else, if numbers are
not in O(n), we have to sort and do what i said earlier.

So if the array is unsorted, we can get it done only in O(nlgn).

-VijayOn 12/20/05, Hemanth <[EMAIL PROTECTED]> wrote:
Hi,Let me try to slightly present the problem in a different way.1. First go through the unsorted array and get two smaller arrays. Onearray containing numbers <= z/2 and other array containing numbers >
z/2 and <= z. Other numbers obviously can be ignored.2. Now 'z' complement(i.e. number = z - number)  all the numbers in thearray which has numbers <= z/2.3. The problem now is to find if any number in this complement array
repeats in the other array in O(n) time.Am currently trying to find a solution to this will get back assoon as I get an answer.


[algogeeks] Re: Given N numbers & z value , find x, y such that x + y = z

2005-12-19 Thread Vijay Venkat Raghavan N
Hi,

I guess this has already been discuss in this forum before. Anyways let
me give my algo here. Let us assume that the array is sorted in
ascending order WLOG. 

let low=1 and high=n index the first and last elements
while(low
{
if a[low]+a[high] == z, done, so break off
if a[low]+a[high]
3rd case, u need to decrease, so high--
}

hope this helps.

-VijayOn 12/19/05, Uppala Babu <[EMAIL PROTECTED]> wrote:
Hash map takes extra space if you want O(1) search..
Otherwise .. it takes time... any another solution...

in O(n) time with no extra space.. ;-)On 12/19/05, Hemanth <
[EMAIL PROTECTED]> wrote:
This answer is something like a bit vector based one.Assume that the array is int[] num.for(int i = 0; i < num.length; i++){int otherNum = z - num[i];// Search in a hashmap we maintain for 'otherNum'
// if 'otherNum' is present, then we are done// else add 'num[i]' to the hashmap and proceed// to the next iteration.}




[algogeeks] Re: Comparing two mathematical expressions

2005-12-15 Thread Vijay Venkat Raghavan N
Hi Pramod,

My algo has a long way to go. It really has to be tailored to
accomodate all stray cases, dividing by a reciprocal is certainly one
of them. In any case, I thought it was a fairly structured way of
solving, if not all, at least say some 40% of the cases. 

In any case, if you want a complete algorithm that can do this, then
are we not bordering on the NP complete satisfiability problem. We are
actually making matters worse as variables are not just binary valued,
but could take any value. So in my opinion, a complete algorithm that
can compare any 2 given equations is not possible in polynomial time.

-VijayOn 12/15/05, pramod <[EMAIL PROTECTED]> wrote:
Vijay,Your algo is not clear to me.Let's take the original example given by moop.(a+b)*(c-d) whose lexicographic sorting will give (a+b)*(c-d)and second _expression_ is (c-d)/(1/(b+a)) whose lexicographic sorting
will give(c-d)/(1/(a+b))These two are not the same, so what you propose to do?


[algogeeks] Re: Comparing two mathematical expressions

2005-12-14 Thread Vijay Venkat Raghavan N
Hi folks,

Lets do a lexicographical sorting of the _expression_ like this:

Exp Lexico (E1 Opr E2)
{
 newE1= Lexico(E1);
 newE2= Lexico(E2);
 if( Opr is NON Commutative  ) return  "newE1 opr newE2"; 

    //If Opr is Commutative 
    If newE1 lexicographicallysmallerthan newE2
   return "newE1 Opr newE2";
    else return "newE2 Opr newE1";

}

Of course base condition is expressions with no operator. 

Possible problems I can see are due to associativity. If the overall _expression_ is somethng like
E1+E2+E3, we can take the initial split to be E1+(E2+E3) or otherwise. I am reminded of the matrix chain multiplication DP.
anyways guys, jus throw in ur comments on this.

-Vijay
On 12/14/05, moop™ <[EMAIL PROTECTED]> wrote:
If put in the value the two expressions are resulted in differentvalues, we can sure they are different in some of the ways;but what if they have the same results, can we guarantee they are thesame _expression_?



[algogeeks] Re: Geometry problems

2005-12-01 Thread Vijay Venkat Raghavan N
Hi,

But the 2 slopes may not have a common point. If that is not so, they
are jus referring to 2 parallel lines and not 3 collinear points.

-VijayOn 12/1/05, forest <[EMAIL PROTECTED]> wrote:
You can do without matrix, sort ALL slopes and then find 2 adjacentequal, as sorting n^2 is O(n^2 log (n^2)) = O(2n^2 log n) = O(n^2 log n)


[algogeeks] Re: Design an algorithm

2005-11-30 Thread Vijay Venkat Raghavan N
Hi,

So do u mean to say that we can leave out those numbers which are less
than the median of medians and greater than the median of medians in
each round? If yes, I have a case to prove this algo wrong.

-VijayOn 12/1/05, pramod <[EMAIL PROTECTED]> wrote:
Let M1,M2, ..., MN be the medians and let MM be the median of medians.So (N-1)/2 medians are less than MM and (N-1)/2 medians are greaterthan MM.Since each of these medians has (N-1)/2 elements less and greater than
themselves within each computer, there are (N-1)/2*(N-1)/2 (this is Imentioned *around* N^2/4) elements less than MM and same number greaterthan MM. What exactly are these numbers is obtained by partitioning.
Overall time complexity is O(N) with all computers running parallelsince each step takes O(N) time.


[algogeeks] Re: Geometry problems

2005-11-30 Thread Vijay Venkat Raghavan N
hi, 

i have an answer to ur first question. it is n^2 lgn, but its quite a
long procedure and I am sure there must be somethng better.

1. set up and nXn matrix, where the entry at (i,j) is the directed slope between points i and j. this is n^2
2. sort each row of this matrix. sorting one row is nlogn, and n rows leads to n^2 lgn
3. Finally traverse each row and find out if adjacent elements are the same.

So in essence I am seeing if the slope of the line between point i and
point j, is same as that between point i and point k. if so, i,j and k
they are collinear. 

One general request to all of u. Lets have jus one question per thread.
So there will be a coherance across the entire thread if we discuss
only one prob.

-VijayOn 11/30/05, pramod <[EMAIL PROTECTED]> wrote:
1) Design a O (n^2 log(n) ) algorithm to find if any three points in aset of n points in a plane are collinear2) Design a O(n log(n) ) algorithm to check if two simple polygonsintersect



[algogeeks] Re: how to find Previous Prime number?

2005-11-30 Thread Vijay Venkat Raghavan N
Hi,

Well lots of posts abt primality testing. But what my frnd Venks wants
is not a linear algo, not something like, run down from that number
till u get a prime and use an efficient method to do ur primality
testing. what i presume he wants is a way of jumping over numbers
without missing any primes inbetween.  of course i dont have an
asnwer, not even sure if one exists, but i guess this is what we shd be
discussing.

-VijayOn 11/30/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]> wrote:
Well sorry...Kindly excuse my ignorance...I believe nothing is known about the class to which the factorizationproblem belongs to...As with the AKS algorithm... yes! "primes is in p" but many more primality
testing algorithms are also known to run in P type provided the extendedriemann hypothesis is assumed...Nice to see some primo discussions on an algo group :-)Keep posting.sudarshan
- Original Message -From: "Dhyanesh" <[EMAIL PROTECTED]>To: Sent: Wednesday, November 30, 2005 8:41 PMSubject: [algogeeks] Re: how to find Previous Prime number?HiIt is not an NP complete problem, it has been one of the open problemsfor quite some time.  And by the way determining whether a number is
prime or not is surely not NP, it is in P. This is not an approximatealgorithm or anything. Here is the link to the paper:http://www.cse.iitk.ac.in/users/manindra/primality_original.pdf
Also read the last paragraph on this link:http://www.guajara.com/wiki/en/wikipedia/c/co/co_np.html-DhyaneshOn 11/30/05, SUDARSHAN IYENGAR <
[EMAIL PROTECTED]> wrote:>> factoring is an np complete problem. No change of having a simplealgorithm> for it.>> -sudarshan
>> - Original Message -> From: "Dhyanesh" <[EMAIL PROTECTED]>> To: <
algogeeks@googlegroups.com>> Sent: Wednesday, November 30, 2005 7:47 AM> Subject: [algogeeks] Re: how to find Previous Prime number? I believe there is an N^12 algorithm for integer factorization ... so
> it isnt all that hard i think ...>> On 11/29/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]> wrote:> >> > primality testing is a very very very tough topic to discuss...
> >> >> > There is no single algorithm for primality testing... and all that is> known> > so far is nothing but intelligent brute forcing...> >> > try peeping through 
http://primepages.org more like a bible for prime> number> > lovers.> >> > -Sudarshan> >> >> >> > The hardest thing to understand is why we can
> > understand anything at all>
>  
- Einstein> > - Original Message -> > From: "Venkatesh Dayalan" <[EMAIL PROTECTED]>> > To: <
algogeeks@googlegroups.com>> > Sent: Tuesday, November 29, 2005 7:53 PM> > Subject: [algogeeks] Re: how to find Previous Prime number?> >> >> > thanks for the info
> > but i am looking into the logic of finding the previous prime number...> >> >> > On 11/29/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]
> wrote:> > >> > >> > > hey well... you must have a look at this package "pari gp"> > >> > > try googling and you can download this package, its very small and is
> the> > > best of its kind available till date... You can also get the code for> the> > > same...> > >> > > -Sudarshan> > >> > >
> > > - Original Message -> > > From: <[EMAIL PROTECTED]>> > > To: "Algorithm Geeks" <
algogeeks@googlegroups.com>> > > Sent: Tuesday, November 29, 2005 7:45 PM> > > Subject: [algogeeks] how to find Previous Prime number?> > >> > >> > > >
> > > > Hi everbody> > > > Given a number which can be as long as 1 digits, is there amethod> > > > to find the previous prime number to it?> > > >
> > > > ~venkatesh> > > >> > >> > >> >> >> > --> > "There is no Spoon"> >> > "asato ma sad gamaya - From delusion lead me to truth
> > tamaso ma jyotir gamaya  - From darkness lead me to light> > mrtyor mamrtam gamaya" - From death lead me to immortality> >> >>>


[algogeeks] Re: Design an algorithm

2005-11-30 Thread Vijay Venkat Raghavan N
Hi pramod,

I dont get the last part of your solution. How does it leave us with
n^2/4 lesser and greater than the median? Also if we leave out
everythng thats lesser or greater than a number, all what should be
left is the number itelf. I am missing something and plz explain your
algo's last part clearly.

Also what is the overall time complexity of the entire procedure?

-VijayOn 12/1/05, pramod <[EMAIL PROTECTED]> wrote:
Each computer finds the median of the numbers it holds. This can bedone in O(n) time and O(n) space by each computer. Now all computerssend their median to a dedicated computer which finds the median of
these medians ( O(n) time and space) and sends this value to all thecomputers. Each computer in turn partitions the numbers it has (O(n)time and space) according to this median of medians and sends how manynumbers are less and greater than the median of medians to the
dedicated computer. This leaves us with around n^2/4 numbers less thanthe median of median and n^2/4 numbers greater than the median ofmedians. So now we need to repeat the process with around n^2/2elements.