Re: [algogeeks] java

2013-03-17 Thread manish untwal
@sasi and Sulekhaits Head First Java...which explained these properties
to me. :)

On Thu, Mar 14, 2013 at 1:28 PM, sasi kumar  wrote:

> @Manish Well Explained:)
> @sulekha Probably  you have to read Head First java which is an awesome
> book that covers these topics with examples
>
>
> On 12 March 2013 21:10, manish untwal  wrote:
>
>> according to my understanding the super class object have limited
>> function like for example
>> Class - animal : methods/behavior : roam() and eat()
>> and a sub class hippo : method/behavior : roam(),eat() and swim()
>> so a hippo is a animal then according to the polymorphic property of java
>> a reference of animal can refer to object of class hippo and animal but
>> still the reference can call only the behavior of class animal i.e : animal
>> A = new hippo() is legal but you can't call A.swim() because it refer to
>> the animal property of class hippo ie roam and eat...not swim. and also u
>> can't do this as hippo H = new animal() as this means animal should have
>> all the property of hippo because it is referred by a hippo reference do
>> H.swim() should not be a NULL.reply if you get it or not.
>> P.S :  I tried to explain it through an example
>>
>> On Tue, Mar 12, 2013 at 8:51 PM, sulekha metta 
>> wrote:
>>
>>> what ever data members,member functions present in super class are
>>> applicable to subclass...subclass may contain more additional
>>> featuresso its obvious that size of subclass object is more than
>>> superclass object...now lets take an analogy of float(4 bytes) and double(
>>> 8 bytes) float can be implicitly converted into double( as float size is
>>> less when compared to double) but not vice versathen why is this not
>>> applicable to superclass object and subclass object(as size of superclass
>>> object is less when compared to subclass)? please tell if am wrong!
>>>
>>>
>>> On Tue, Mar 12, 2013 at 7:37 PM, subramony mahadevan <
>>> subums...@gmail.com> wrote:
>>>
>>>> i think its just a logical reason  take animal as superclass bird
>>>> as subclass ... since we are talking about inheritance it is " is a
>>>> relationship " ie bird is a animal not vice versa hence we cannot
>>>> implicitly convert to subclass
>>>>
>>>>
>>>> On Sat, Mar 2, 2013 at 6:18 PM, sulekha metta 
>>>> wrote:
>>>>
>>>>> Q) why super class object can't be  implicitly converted to subclass?
>>>>> is there any specific reason?
>>>>> Thanks in advance!
>>>>>
>>>>> --
>>>>> sulekha metta
>>>>> B.E computer science
>>>>> osmania university
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> sulekha metta
>>> B.E computer science
>>> osmania university
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>>
>> --
>> With regards,
>> Manish kumar untwal
>> Indian Institute of Information Technology
>> Allahabad (2009-2013 batch)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] java

2013-03-12 Thread manish untwal
according to my understanding the super class object have limited function
like for example
Class - animal : methods/behavior : roam() and eat()
and a sub class hippo : method/behavior : roam(),eat() and swim()
so a hippo is a animal then according to the polymorphic property of java
a reference of animal can refer to object of class hippo and animal but
still the reference can call only the behavior of class animal i.e : animal
A = new hippo() is legal but you can't call A.swim() because it refer to
the animal property of class hippo ie roam and eat...not swim. and also u
can't do this as hippo H = new animal() as this means animal should have
all the property of hippo because it is referred by a hippo reference do
H.swim() should not be a NULL.reply if you get it or not.
P.S :  I tried to explain it through an example

On Tue, Mar 12, 2013 at 8:51 PM, sulekha metta wrote:

> what ever data members,member functions present in super class are
> applicable to subclass...subclass may contain more additional
> featuresso its obvious that size of subclass object is more than
> superclass object...now lets take an analogy of float(4 bytes) and double(
> 8 bytes) float can be implicitly converted into double( as float size is
> less when compared to double) but not vice versathen why is this not
> applicable to superclass object and subclass object(as size of superclass
> object is less when compared to subclass)? please tell if am wrong!
>
>
> On Tue, Mar 12, 2013 at 7:37 PM, subramony mahadevan 
> wrote:
>
>> i think its just a logical reason  take animal as superclass bird as
>> subclass ... since we are talking about inheritance it is " is a
>> relationship " ie bird is a animal not vice versa hence we cannot
>> implicitly convert to subclass
>>
>>
>> On Sat, Mar 2, 2013 at 6:18 PM, sulekha metta wrote:
>>
>>> Q) why super class object can't be  implicitly converted to subclass? is
>>> there any specific reason?
>>> Thanks in advance!
>>>
>>> --
>>> sulekha metta
>>> B.E computer science
>>> osmania university
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> sulekha metta
> B.E computer science
> osmania university
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] java

2013-03-12 Thread manish untwal
didn't understand your question please specify the question with an example.

On Sat, Mar 2, 2013 at 6:18 PM, sulekha metta wrote:

> Q) why super class object can't be  implicitly converted to subclass? is
> there any specific reason?
> Thanks in advance!
>
> --
> sulekha metta
> B.E computer science
> osmania university
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Adobe Interview Question

2012-12-16 Thread manish untwal
file redirection!! i did that too i was finding myself helplessi
tried every thing!! as a result, i missed on this question

On Wed, Dec 12, 2012 at 8:53 AM, saurabh singh  wrote:

> I would have replied back with I am doing it with C programming language
> only. the read function that we use is not an actual system call. It is a
> *wrapper to a system call*. Any other function that we use usually ends
> up in calling some system call. The actual system call is called by low
> level routines.
> If he still disagreed I would have given him this solution:
>
> #include
> int main()
> {
> int ch;
> while((ch=getchar())!=-1) putchar(ch);
> return 0;
> }
>
> Would have run this as *./a.out < file_to_read*
> *
> *
> If he still disagreed I would have walked out :P
>
>
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
>
>
> On Tue, Dec 11, 2012 at 11:23 PM, manish untwal 
> wrote:
>
>> i answered with the...system call too..but he said...do it in C
>> programming language only don't use...system call here!!
>>
>> On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh wrote:
>>
>>> stdin is a file pointer.
>>> freopen returns a file pointer..
>>> I suggest using read system call.
>>>
>>> For the second question it would be simply
>>> (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
>>>
>>> However this will also contains permutations which begin with 0. So
>>> subtract the number of permutations that begin with 0 from this number.
>>>
>>> Since any factorial in the denominator part will be less than or equal
>>> to (len)! we can calculate and store them while calculating len! Hence the
>>> overall operation will take O(len) time which would be O(log n) where n is
>>> the number.
>>>
>>> Saurabh Singh
>>> B.Tech (Computer Science)
>>> MNNIT
>>> blog:geekinessthecoolway.blogspot.com
>>>
>>>
>>>
>>> On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
>>> wrote:
>>>
>>>> 1st:
>>>>
>>>> freopen("filename","r",stdin);
>>>>
>>>> while(scanf("%s",str)!=-1)
>>>> {
>>>> printf("%s\n",str);
>>>> }
>>>>
>>>>
>>>> On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
>>>> wrote:
>>>>
>>>>> I gave this interview in August this year, two of the question i was
>>>>> not able to answer properly
>>>>> 1) how to print the content of file in C without using the file
>>>>> pointer.
>>>>> 2) count the total number of permutation of a number in order O(n)
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Thanks & Regards
>>>> Amritpal singh
>>>>
>>>>  --
>>>>
>>>>
>>>>
>>>
>>>  --
>>>
>>>
>>>
>>
>>
>>
>> --
>> With regards,
>> Manish kumar untwal
>> Indian Institute of Information Technology
>> Allahabad (2009-2013 batch)
>>
>>  --
>>
>>
>>
>
>  --
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 




Re: [algogeeks] Adobe Interview Question

2012-12-11 Thread manish untwal
i answered with the...system call too..but he said...do it in C programming
language only don't use...system call here!!

On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh  wrote:

> stdin is a file pointer.
> freopen returns a file pointer..
> I suggest using read system call.
>
> For the second question it would be simply
> (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
>
> However this will also contains permutations which begin with 0. So
> subtract the number of permutations that begin with 0 from this number.
>
> Since any factorial in the denominator part will be less than or equal to
> (len)! we can calculate and store them while calculating len! Hence the
> overall operation will take O(len) time which would be O(log n) where n is
> the number.
>
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
>
>
> On Tue, Dec 11, 2012 at 11:02 AM, amrit harry wrote:
>
>> 1st:
>>
>> freopen("filename","r",stdin);
>>
>> while(scanf("%s",str)!=-1)
>> {
>> printf("%s\n",str);
>> }
>>
>>
>> On Sun, Dec 9, 2012 at 3:22 PM, manish untwal wrote:
>>
>>> I gave this interview in August this year, two of the question i was not
>>> able to answer properly
>>> 1) how to print the content of file in C without using the file pointer.
>>> 2) count the total number of permutation of a number in order O(n)
>>>
>>> --
>>>
>>>
>>>
>>
>>
>>
>> --
>> Thanks & Regards
>> Amritpal singh
>>
>>  --
>>
>>
>>
>
>  --
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 




Re: [algogeeks] Adobe Interview Question

2012-12-11 Thread manish untwal
i think, i replied with the same answer and he was not convinced

On Tue, Dec 11, 2012 at 11:02 AM, amrit harry wrote:

> 1st:
>
> freopen("filename","r",stdin);
>
> while(scanf("%s",str)!=-1)
> {
> printf("%s\n",str);
> }
>
>
> On Sun, Dec 9, 2012 at 3:22 PM, manish untwal wrote:
>
>> I gave this interview in August this year, two of the question i was not
>> able to answer properly
>> 1) how to print the content of file in C without using the file pointer.
>> 2) count the total number of permutation of a number in order O(n)
>>
>> --
>>
>>
>>
>
>
>
> --
> Thanks & Regards
> Amritpal singh
>
>  --
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 




Re: [algogeeks] Array Problem

2012-12-11 Thread manish untwal
@wladimir yes the problem seems to be that!!

On Tue, Dec 11, 2012 at 10:13 AM, Wladimir Tavares wrote:

> subset sum?
> Wladimir Araujo Tavares
> *Federal University of Ceará <http://lia.ufc.br/%7Ewladimir/>
> Homepage <http://lia.ufc.br/%7Ewladimir/> | 
> Maratona<https://sites.google.com/site/quixadamaratona/>|
> *
>
>
>
>
>
> On Fri, Nov 16, 2012 at 2:46 AM, Pralay Biswas  > wrote:
>
>> Search for balance partitioning under Dynamic Programming. Doable in O(n)
>>
>>
>> On Thu, Nov 15, 2012 at 8:16 PM, bharat b 
>> wrote:
>>
>>> @ vishal : how can u divide an array into 2 groups whose difference is
>>> maximum in O(1). why max?
>>>
>>> solution : http://www.youtube.com/watch?v=GdnpQY2j064
>>>
>>>
>>>
>>>
>>> On Fri, Nov 16, 2012 at 9:22 AM, vishal chaudhary <
>>> vishal.cs.b...@gmail.com> wrote:
>>>
>>>> Hi
>>>> you can first sort the array which can be done in O(nlogn) complexity
>>>> if the number of items in the array is n.
>>>> Then using the indexing of arrays you can divide the array into two
>>>> groups whose difference is going to be maximum and this can be done in O(1)
>>>> complexity.
>>>> So the complete algorithm is going to take O(nlogn) complexity.
>>>> Kindly share an alternative algorithm if you find  one with lower
>>>> complexity.
>>>>
>>>> Vishal
>>>>
>>>>
>>>> On Wed, Nov 7, 2012 at 7:43 PM, Arun Kindra <
>>>> reserve4placem...@gmail.com> wrote:
>>>>
>>>>> Given an unsorted array, how to divide them into two equal arrays
>>>>> whose difference of sum is minimum.
>>>>>
>>>>> --
>>>>> 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.
>>>
>>
>>  --
>>
>>
>>
>
>  --
>
>
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 




[algogeeks] Adobe Interview Question

2012-12-10 Thread manish untwal
I gave this interview in August this year, two of the question i was not 
able to answer properly
1) how to print the content of file in C without using the file pointer.
2) count the total number of permutation of a number in order O(n)

-- 




[algogeeks] os question

2012-12-06 Thread manish
 Four processes of 1gb,1.2gb,2gb,2gb are there and RAM available is 2gb. We 
have a
time shared system. Which of the following is the most appropriate 
scheduling algorithm?
a. all processes are loaded sequentially 1 by 1
b. load one process at a time and execute processes in RR fashion
c. load 1gb, 1,2gb first then processes 3 and 4 follow
d. All processes can be loaded together and CPU time shared among them

-- 




[algogeeks] swap objects without temp variable

2012-11-04 Thread manish
Swapping two objects (not integers/chars),without using temp...?
my solution is using xor operation..is that right and ny other solutions ?

-- 
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/-/OxVSnZ1QjzMJ.
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] OS question..

2012-11-04 Thread manish
Q1.  If we have infinite memory, then do we still be needing paging?
Q2. Given only 8bits registers, you have to find average of 4 bit registers 
values without using any operation involving 16 bit calculations.

-- 
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/-/iUT57I-DOHoJ.
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] BST to DLL code: whats wrong with this code........

2012-09-03 Thread manish untwal
if u r getting desired output ? then what is the problem?

On Sun, Sep 2, 2012 at 7:24 PM, shubham jain wrote:

> Hi
> I am trying to convert the BST to doubly linked list but I  am  getting
> desired output with this code Plz correct this code.
>
> #include
> #include
> typedef struct tree mytree;
> struct tree
> {
>int data;
>mytree* left;
>mytree* right;
> };
>
> void insert(mytree** root,int data)
> {
>   if(*root==NULL)
>   {
>   mytree* node=(mytree*)malloc(sizeof(mytree));
>   if(node==NULL)
>   return;
>   else
>   {
> node->data=data;
> node->left=NULL;
> node->right=NULL;
>   }
>
>   *root=node;
> return;
>   }
>   else
>   {
>  if((*root)->data >=data)
>insert(&(*root)->left,data);
> else
>insert(&(*root)->right,data);
>   }
> }
>
> void traverse(mytree* ptr)
> {
>   if(ptr==NULL)  return;
>   traverse(ptr->left);
>   printf("%d\t",ptr->data);
>   traverse(ptr->right);
> }
>
> void traversell(mytree* ptr)
> {
>   if(ptr==NULL)  return;
>   while(ptr!=NULL)
>   {
>   printf("%d\t",ptr->data);
>   ptr=ptr->right;
>   }
>
> }
>
> void bst22ll(mytree** tree,mytree** head)
> {
>static mytree* prev=NULL;
>if(*tree==NULL)  return;
>mytree* ptr=*tree;
>if((*tree)->left!=NULL)
>bst22ll(&(*tree)->left,head);
>*tree=ptr;
>if(*head==NULL)
> {
>   *head=*tree;
>   (*head)->left==NULL;
> }
>else
> {
>   prev->right=*tree;
>   (*tree)->left=prev;
> }
> prev=*tree;
>
>if((*tree)->right!=NULL)
>  {
>  bst22ll(&(*tree)->right,head);
>  }
> }
>
>
>
> void bst2ll(mytree** tree)
> {
>   if(tree==NULL)  return;
>   mytree* head=NULL;
>   mytree* prev=NULL;
>   bst22ll(tree,&head);
>   *tree=head;
> }
>
> int main()
> {
> mytree* tree=NULL;
> insert(&tree,50);
> insert(&tree,40);
> insert(&tree,60);
> insert(&tree,30);
> insert(&tree,70);
> insert(&tree,65);
> insert(&tree,45);
> insert(&tree,34);
> traverse(tree);
> bst2ll(&tree);
> printf("\n");
> traversell(tree);
> printf("\n");
> }
>
>
> should print : 30  34  40  45  50  60  65 70
> but printing:   30  34  40  45  50  60  70
>
>
> Thank you
> Shubham
>
> --
> 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/-/XXMvBSg0t08J.
> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
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] DE Shaw written test

2012-08-07 Thread manish patel
This is maximum sub-array problem. Nice explaination is given in CLRS -
"Introduction to algorithms " Pg 68, ch-4 3rd edition

On Tue, Aug 7, 2012 at 11:00 AM, Navin Gupta  wrote:

> @ashgoel :- Thanx for pointing it out, my earlier approach doesn't work.
> Please check if this works.
> We can apply this:-
>  For every  element, find the highest element to the right of it.
> For e.g:
> I/P:- 35   4015   35   10 20
> Highest to Right:-  40   3535   20   20-
>
> Now at every point, we will find the difference of both and  keep track of
> the buy and sell dates.
> This can be done in linear time without any space.
>
> void getDates(  int price[]  ) {
> int maxSel l, maxBuy , maxGain= INT_MIN;
> int Sell,Buy,curGain;
> Sell = n;
> for(int i=n-1;i>=0;i--)
> {
> curGain = price[Sell] - price[i];
> if(curGain > maxGain){  // buying today gives more gain
> that previous gain found, update the maxgain and buy,sell dates
> maxGain = curGain;
> maxBuy = i;// today
> maxSell = Sell;
> }
> if( price[i]  >  price[Sell] ) // here selldate is
> updated
> Sell =  i ;
>
> }
> }
>
>  --
> 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/-/BrQFNo1PKTIJ.
>
> 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.
>



-- 
With Regards

Manish Patel
BTech Final year
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] Microsoft online questions

2012-07-31 Thread manish untwal
egroups.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.
>>>
>>>
>>
>>
>> --
>> - - - - - - - - - - - -
>> With Regards
>> Daksh Talwar
>>
>> --
>> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
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] directi paper pattern

2012-07-31 Thread manish untwal
hey friends they repeat there paper a lot!! that is they asked the same
question for the interns too last year. It was too difficult.

On Tue, Jul 31, 2012 at 9:52 PM, Avinash Mishra
wrote:

> hey please mail me too...please give a pastebin link
>
>
> On 31 July 2012 21:51, neelpulse(Jadavpur University)  > wrote:
>
>> Hey, can you please mail me too?
>>
>> -Thanks
>> Nilanjan Basu
>>
>>
>> On Tuesday, July 31, 2012 9:49:15 PM UTC+5:30, MUDIT wrote:
>>>
>>>
>>> Please forward the mail to me as well.
>>> Thanks
>>>
>>> --
>>> Mudit Sadana
>>> Undergraduate Student,Computer Science
>>>  NSIT, Delhi University,India
>>>
>>>   --
>> 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/-/2YdFa0ZwOIsJ.
>>
>> 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.
>>
>
>
>
> --
> With regard's
> Avinash
>
>  --
> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
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] directi paper pattern

2012-07-31 Thread manish untwal
hey they repeat their paper alot,i.e they asked the same paper last year in
our institute for the intern!! so best of luck

On Tue, Jul 31, 2012 at 9:52 PM, Avinash Mishra
wrote:

> hey please mail me too...please give a pastebin link
>
>
> On 31 July 2012 21:51, neelpulse(Jadavpur University)  > wrote:
>
>> Hey, can you please mail me too?
>>
>> -Thanks
>> Nilanjan Basu
>>
>>
>> On Tuesday, July 31, 2012 9:49:15 PM UTC+5:30, MUDIT wrote:
>>>
>>>
>>> Please forward the mail to me as well.
>>> Thanks
>>>
>>> --
>>> Mudit Sadana
>>> Undergraduate Student,Computer Science
>>>  NSIT, Delhi University,India
>>>
>>>   --
>> 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/-/2YdFa0ZwOIsJ.
>>
>> 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.
>>
>
>
>
> --
> With regard's
> Avinash
>
>  --
> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

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

2012-07-26 Thread Manish Patidar
20
Thank you,
Have a great day !!


   * With Regards,
*
*
Manish Patidar.*



On Thu, Jul 26, 2012 at 11:11 PM, payal gupta  wrote:

> ans.20
>
>
> On Thu, Jul 26, 2012 at 11:09 PM, Ali Ahmad Ansari <
> ali.ahamad.ans...@gmail.com> wrote:
>
>> Given a number N, generate a sequence S such that
>> S[ 0 ] = N
>> S[ i+1 ] = (3 * S[ i ] + 1) / 2 if S[ i ] is odd,
>> = S[ i ] / 2, if S[ i ] is even,
>> till you reach 1.
>> For example for N = 5, the sequence is 5, 8, 4, 2, 1
>> Given two numbers 20 and 35, generate the sequence S for A
>> and B, and find the number where the two sequences meet.
>> a.20
>> b.30
>> c.35
>> d.40
>>
>> --
>> 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/-/EEhTdWZgDrQJ.
>> 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]

2012-07-26 Thread manish untwal
#include 
#include 

using namespace std;

int main()
{
string s;
string str = "";
cin >> s;
char pre;
for(int i = 0; i < s.length(); i++) {
if(47 < s[i] and s[i] < 58){
while((s[i]-48) > 1) {
str += pre;
s[i]--;
}
}
if(96 < s[i] and s[i] < 123) {
str += s[i];
pre = s[i];
}
//cout << str << endl;
}
cout << str;
return 0;
}

On Wed, Jul 25, 2012 at 6:46 AM, Sathish babu wrote:

> can anyone provide the code to convert ab1cd3 to  abcddd
> **~Sathish Babu~**
>
>
>
> On Tue, Jul 24, 2012 at 11:39 PM, Mind Boggler  wrote:
>
>> Traditional decryption problem
>> Convert a3b2c5 into aaabbc
>> Can anyone Put forward an algo for the test case: a3b1c3d1
>> Thanx
>>
>> --
>> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
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] Directi Written Q 2012

2012-07-24 Thread manish untwal
and we don't need the code!!

On Tue, Jul 24, 2012 at 10:30 PM, manish untwal wrote:

> I think the question is in the written round!!!
>
>
> On Tue, Jul 24, 2012 at 9:11 PM, algo bard  wrote:
>
>> #include
>> #define RANGE_START 0
>> #define RANGE_END 100
>>
>> int main()
>> {
>> int i,n,ctr=0;
>>
>> for( i=RANGE_START ; i<=RANGE_END ; i++)
>> {
>> n = i;
>> while(n)  // Using Brian Kernighan's Algorithm to count the
>> number of set bits in a number.
>> {
>> n= n&n-1;
>> ctr++;
>> }
>>
>> }
>>
>> printf("%d ",ctr);
>> }
>>
>> TC = No. of set bits in the given range of numbers.
>>
>>
>> On Tue, Jul 24, 2012 at 7:56 PM, Lomash Goyal wrote:
>>
>>> // count number of 1's upto n.cpp : Defines the entry point for the
>>> console application.
>>> //
>>>
>>> #include "stdafx.h"
>>> #include
>>> #include
>>>  //the following functions will count number of bits in the number
>>> int countbits(int n)
>>> {
>>>int count=0;
>>>while(n)
>>>   {
>>> n/=2;
>>> count++;
>>>   }
>>> return count;
>>> }
>>>
>>>
>>> int countnumberof1(int number)
>>> {
>>> if(number==0)
>>>  return 0;
>>> if(number==1)
>>> return 1;
>>>  if(number==2)
>>> return 2;
>>> if(number==3)
>>>  return 4;
>>>  if(number>3)
>>>  {
>>> int bits=countbits(number);
>>> if(number==pow(2.0,bits)-1)
>>>  {
>>> return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
>>> }
>>>  else return
>>> pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
>>> }
>>> }
>>> int _tmain(int argc, _TCHAR* argv[])
>>> {
>>> printf("%d",countnumberof1(10));
>>> getch();
>>>  return 0;
>>> }
>>>
>>>
>>> On Tue, Jul 24, 2012 at 3:09 PM, ruru  wrote:
>>>
>>>> find no. of 1's in binary format of numbers from 1 to 100. like for
>>>> 1 to 10 answer is 17
>>>>
>>>> --
>>>> 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
>>>
>>> Lomash Goyal
>>>
>>> *
>>> *
>>>
>>>
>>>  --
>>> 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.
>>
>
>
>
> --
> With regards,
> Manish kumar untwal
> Indian Institute of Information Technology
> Allahabad (2009-2013 batch)
>
>


-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

-- 
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] Directi Written Q 2012

2012-07-24 Thread manish untwal
I think the question is in the written round!!!

On Tue, Jul 24, 2012 at 9:11 PM, algo bard  wrote:

> #include
> #define RANGE_START 0
> #define RANGE_END 100
>
> int main()
> {
> int i,n,ctr=0;
>
> for( i=RANGE_START ; i<=RANGE_END ; i++)
> {
> n = i;
> while(n)  // Using Brian Kernighan's Algorithm to count the number
> of set bits in a number.
> {
> n= n&n-1;
> ctr++;
> }
>
> }
>
> printf("%d ",ctr);
> }
>
> TC = No. of set bits in the given range of numbers.
>
>
> On Tue, Jul 24, 2012 at 7:56 PM, Lomash Goyal wrote:
>
>> // count number of 1's upto n.cpp : Defines the entry point for the
>> console application.
>> //
>>
>> #include "stdafx.h"
>> #include
>> #include
>>  //the following functions will count number of bits in the number
>> int countbits(int n)
>> {
>>int count=0;
>>while(n)
>>   {
>> n/=2;
>> count++;
>>   }
>> return count;
>> }
>>
>>
>> int countnumberof1(int number)
>> {
>> if(number==0)
>>  return 0;
>> if(number==1)
>> return 1;
>>  if(number==2)
>> return 2;
>> if(number==3)
>>  return 4;
>>  if(number>3)
>>  {
>> int bits=countbits(number);
>> if(number==pow(2.0,bits)-1)
>>  {
>> return pow(2.0,bits-1)+2*countnumberof1(pow(2.0,bits-1)-1);
>> }
>>  else return
>> pow(2.0,bits-2)+2*countnumberof1(pow(2.0,bits-2)-1)+countnumberof1(number-(pow(2.0,bits-1)))+number-(pow(2.0,bits-1))+1;
>> }
>> }
>> int _tmain(int argc, _TCHAR* argv[])
>> {
>> printf("%d",countnumberof1(10));
>> getch();
>>  return 0;
>> }
>>
>>
>> On Tue, Jul 24, 2012 at 3:09 PM, ruru  wrote:
>>
>>> find no. of 1's in binary format of numbers from 1 to 100. like for
>>> 1 to 10 answer is 17
>>>
>>> --
>>> 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
>>
>> Lomash Goyal
>>
>> *
>> *
>>
>>
>>  --
>> 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.
>



-- 
With regards,
Manish kumar untwal
Indian Institute of Information Technology
Allahabad (2009-2013 batch)

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

2012-02-12 Thread manish patel
Let the source and destination vertices be s and t.

We need to compute Best[s,t,10]. Best[x,y,t] is best path between x to y of
t hops.

The recurrence is


Best[u,v,m] =  min_{over all u'} [ max {Distance(u,u'), Best[u',v, m-1]} ]

Best[u,v,1] is easy to calculate.

-Courtesy: http://www.careercup.com


On Fri, Feb 10, 2012 at 11:47 AM, praveen raj  wrote:

> choose greedy algorithm... in in minimum spanning tree..
>
> PRAVEEN RAJ
> DELHI COLLEGE OF ENGINEERING
>
> --
> 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.
>



-- 
With Regards

Manish Patel
BTech
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] Re: algo for number of Hamiltonian (undirected) cycles on the circulant graph C_n(1,2).

2012-01-26 Thread manish patel
thanks Dave and Siddhartha sir.  i think dave sir misinterpreted the a(n)
relation. anyway i wil try to solve this problem using this method.
On Thu, Jan 26, 2012 at 1:36 PM, Siddhartha Banerjee <
thefourrup...@gmail.com> wrote:

> @dave:
> a(n)=a(n-1)+a(n-2)-a(n-5)-2
> is not the same as
>  b(n) = b(n-1) + b(n-2) - b(n-5) with b(n)=a(n)-2.
>  b(n) = b(n-1) + b(n-2) - b(n-5) =>a(n)-2=a(n-1)-2+a(n-2)-2-a(n-5)+2
> =>a(n)=a(n-1)+a(n-2)-a(n-5) which is not the same as original relation.
>
> however the classic approach is still fine, we can have
> | a(n+1) ||  1  1  0  0  0 -1  -2|| a(n)|
> | a(n) ||  1  0  0  0  0  0  0 || a(n-1) |
> | a(n-1)  ||  0  1  0  0  0  0  0 || a(n-2) |
> | a(n-2)  | = |  0  0  1  0  0  0  0 | x | a(n-3) |
> | a(n-3)  ||  0  0  0  1  0  0  0 || a(n-4) |
> | a(n-4)  ||  0  0  0  0  1  0   0|| a(n-5) |
> |1 | | 0  0  0  0  0  0  1|  |1|
>
> to complete the operation in O(log(n))
>
> --
> 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.
>



-- 
With Regards

Manish Patel
BTech
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] COA Question

2011-11-19 Thread Manish Patidar
Need Help to prepare for SYNTEL interview.
plzz send me topics to cover.



Thank you in advance,
Have a great day !!


   * With Regards,
*
*
Manish Patidar.*

-- 
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] Give the logic for it

2011-10-01 Thread Manish Kumar
int median(int arr1[],int arr2[],int N)
{

if(N==2)
{
return ((max(arr1[0],arr1[1])+ min(arr2[0],arr2[1]))/2);
}
int mid=N/2;
if(arr1[mid]==arr2[mid])
 return arr1[mid];
if(arr1[mid]>arr2[mid])
return median(arr1,arr2+N/2,N-N/2);
if(arr1[mid]http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Microsoft

2011-10-01 Thread Manish Verma
Does microsoft hire off-campus???..if yes, then what is their
process???..n what type of questions they ask???...what about
google???

actually i've gone through microsoft's collg hiring process.it was
closebut hard luck,anyway..so gonna try after 6 months.

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

2011-09-30 Thread manish kapur
@adi..
he gave a hint that space used should not b of order of range of numbers but
should depend on how many numbers are inserted...

eg..if range is say 1000...bt u entered only 5 nos ->8,100,202,600,989.
u can use space of order 5..and not 1000

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

2011-09-30 Thread manish kapur
@somnath...can u pls elaborate...
he was looking for an elaborate ans...

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

2011-09-30 Thread manish kapur
u have to perform following tasks in O(1) time
1.)insertion
2.)deletion
3.)searching
no range of input numbers is given
wat data structure will you use?
if u use hashing wat will be the key and value pairs?

-- 
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: SPOJ PIGBANK Problem

2011-09-30 Thread manish patel
thanks man i got it .. :)

On Fri, Sep 30, 2011 at 12:17 AM, Don  wrote:

> I think that it will fail if the value of the coins can be more than
> 50001.
> Don
>
> On Sep 29, 12:35 pm, manish patel  wrote:
> > http://www.spoj.pl/problems/PIGBANK/
> >
> > please suggest some test case where it fails ...
> >
> > [code]
> > #include
> > main()
> > {int t=0,n,e,f,i,j;
> > int p[50002],w[10002];
> > scanf("%d",&t);
> > while(t--)
> > {scanf("%d %d",&e,&f);
> > scanf("%d",&n);
> > for(i=0;i > {scanf("%d %d",&p[i],&w[i]);
> > }
> > int min[f-e+2];
> > for(i=e;i<=f+2;i++)
> > {min[i-e]=50001;
> > }
> > min[0]=0;
> > for(i=e+1;i<=f;i++)
> > {for(j=0;j > {if(w[j]<=(i-e)&& min[i-e-w[j]]+p[j] < min[i-e])
> > min[i-e]=min[i-e-w[j]]+p[j];
> >
> > }
> > }
> > if(min[f-e]==50001||min[f-e]==0)
> > printf("This is impossible.\n");
> > else
> > printf("The minimum amount of money in the piggy-bank is
> > %d.\n",min[f-e]);
> > }
> > return 0;
> >
> > }
> >
> > [/code]
> >
> > --
> > With Regards
> >
> > Manish Patel
> > BTech
> > Computer Science And Engineering
> > National Institute of Technology -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.
>
>


-- 
With Regards

Manish Patel
BTech
Computer Science And Engineering
National Institute of Technology -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.



[algogeeks] Re: prime factorization algo

2011-09-19 Thread Manish Verma
around 999,999,999

or
the link to above pbm is
http://www.spoj.pl/problems/CZ_PROB2/

On Sep 19, 11:45 pm, Rahul  wrote:
> how much big number are You tHINKING
> Rahul
>
> On Mon, Sep 19, 2011 at 2:40 PM, Manish Verma  wrote:
> > does anybody know the fastest algo for prime factorization of a
> > number???
>
> > --
> > 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 
> > athttp://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] prime factorization algo

2011-09-19 Thread Manish Verma
does anybody know the fastest algo for prime factorization of a
number???

-- 
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: subarray wid sum=k

2011-09-13 Thread manish kapur
bt how to modify it for getting sum value= k?

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

2011-09-08 Thread Manish Verma
Hey, anyone preparing for acm-icpc

what about discussing acm-icpc questions here
what say @shady??

-- 
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: subarray wid sum=k

2011-09-02 Thread manish kapur
@ashima..wat will b the complexity of ur algo?

-- 
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: subarray wid sum=k

2011-09-02 Thread manish kapur
@bharatkumar..cn u pls share the algo

-- 
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: subarray wid sum=k

2011-09-02 Thread manish kapur
r u sure space used is O(n)?

-- 
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] subarray wid sum=k

2011-09-02 Thread manish kapur
u have 2 find a continuous subarray...

-- 
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] subarray wid sum=k

2011-09-01 Thread manish kapur
given an unsorted array of +ve and -ve elements.find a subarray with sum= k
 in O(n).
you can use some extra space

-- 
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] print level by level withoust recursion

2011-08-31 Thread manish kapur
i think hint is mentioned in the ques..there is an extra pointer..u can take
it as parent pointer..

On Wed, Aug 31, 2011 at 10:13 PM, Abhishek Yadav  wrote:

> can we use loops or GOTO statements
>
> On Wed, Aug 31, 2011 at 10:03 PM, manish kapur  > wrote:
>
>> Given a binary Tree and a node pointer extra in a tree. print all the node
>> level by level. You cannot use any Stack ,recursion and queue.
>>
>> --
>> 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] print level by level withoust recursion

2011-08-31 Thread manish kapur
Given a binary Tree and a node pointer extra in a tree. print all the node
level by level. You cannot use any Stack ,recursion and queue.

-- 
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] microsoft interview

2011-08-31 Thread manish kapur
@anup

check ur algo 4 dis..


0010


-- 
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] microsoft interview

2011-08-31 Thread manish kapur
Input is a matrix of size n x m of 0s and 1s.

eg:
1 0 0 1
0 0 1 0
0 0 0 0

If a location has 1; make all the elements of that row and column = 1. eg

1 1 1 1
1 1 1 1
1 0 1 1

Solution should be with Time complexity = O(n*m) and O(1) extra space

-- 
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 written test ques

2011-08-30 Thread manish kapur
mplement a func node *(char *word){}
wich returns a link list of words dat are anagrams with the input word..if
no anagrams found return NULL and add that word to the link list

given structure of list as
struct node {
struct node *next;
char val[101];
};

-- 
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: Adding Two no without using any operator...??

2011-08-29 Thread manish patel
Awesome Saurabh.
Hats off man:)

On Mon, Aug 29, 2011 at 2:43 PM, saurabh singh  wrote:

> @dave well that was basically a query if it is possible to eliminate all
> the operators and do something like addition operation.I am sorry if I
> presentted my question in the wrong wayI am bad at explaining things.:(
> Going by your previous records I am not elibigle to contradict you.
>
>
> On Mon, Aug 29, 2011 at 9:02 AM, Dave  wrote:
>
>> @Saurabh: Function calls and commas are operators, so that leaves out
>> your clever printf solution.
>>
>> See
>> http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Other_operators.
>>
>> Dave
>>
>> On Aug 28, 9:32 pm, saurabh singh  wrote:
>> > @dave even '=' is an operator.I wonder if its possible to restrict
>> *all
>> > operators*.
>> >
>> >
>> >
>> >
>> >
>> > On Sun, Aug 28, 2011 at 1:32 AM, Dave  wrote:
>> > > @Brijesh: Maybe you mean
>> >
>> > > char *p;
>> > > p = (char*)a;
>> > > sum = (int)&p[b]; // sum = a + b
>> >
>> > > but & is an operator.
>> >
>> > > Dave
>> >
>> > > On Aug 27, 2:07 pm, Brijesh  wrote:
>> > > > How to add two nos without using any operator...?
>> >
>> > > --
>> > > 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.
>> >
>> > --
>> > Saurabh Singh
>> > B.Tech (Computer Science)
>> > MNNIT ALLAHABAD- 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.
>>
>>
>
>
> --
> Saurabh Singh
> B.Tech (Computer Science)
> 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.
>



-- 
With Regards

Manish Patel
BTech
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] c doubt

2011-08-28 Thread manish patel
it will be 00.

Bit fields are allocated within an integer from least-significant to
most-significant bit. In the following code

struct mybitfields
{
unsigned short a : 4;
unsigned short b : 5;
unsigned short c : 7;
} test;

int main( void );
{
test.a = 2;
test.b = 31;
test.c = 0;
}

the bits would be arranged as follows:

0001 0010
cccb 



On Mon, Aug 29, 2011 at 10:31 AM, kartik sachan wrote:

> @PRATEEK if i make int bit1:2 then it will store 2 bytes
> for example if bit1=4;then out will be 0 or 1
> my question is  it storing number from least significant bit or most
> significant bit???
> suppose for 4 0100 so out will be 00 or 01??
>
>  --
> 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.
>



-- 
With Regards

Manish Patel
BTech
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] Apti

2011-08-23 Thread manish patel
(24,33),(12,66),(8,99),(6,132),(4,198),(3,254),(2,396),(1,792),(792,1),(72,11),(264,3),(33,24)

On Tue, Aug 23, 2011 at 10:18 PM, Aman Goyal  wrote:

> Let a natural number N be such that N = a × b where a and b are the factors
> of N. How many such sets of (a, b) can be formed in which the selection of
> the two numbers a and b is distinctly different if N = 24 × 33?
>
> Please explain your solution also.
>
> --
> 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.
>



-- 
With Regards

Manish Patel
BTech 3rd Year
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] apti! solve this!

2011-08-17 Thread manish patel
he is srqt(11^2+5^2)~12.1kms away from A.
if he would hav travelled 4 kms in east then ans would hav been 13kms

On Wed, Aug 17, 2011 at 7:43 PM, priya ramesh <
love.for.programm...@gmail.com> wrote:

>  A moves 3 kms east from his starting point . He then travels 5 kms north.
> From that point he moves 8 kms to the east.How far is A from his starting
> point?
>
> --
> 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.
>



-- 
With Regards

Manish Patel
BTech 3rd Year
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] Adobe Interview Question

2011-08-15 Thread manish patel
actually here jumping of steps mean it can jump over 1 step at max. like if
it is at step no 1 he can jump to 3 as well as 2 but not to 4.
Soln is Fibonacci eqn.
t(n)=t(n-1)+t(n-2);
where t(1)=2 and t(2)=3

On Mon, Aug 15, 2011 at 6:06 PM, Anika Jain  wrote:

> i m sorry i cant understand the question.. if there are n no. steps to
> cross and he can take only one step at a time.. then suppose n=3 then
> obviously doesnt he need to take step 1 first then step 2 then step 3.. ?? m
> confused!
>
>
> On Sun, Aug 14, 2011 at 12:38 AM, Kamakshii Aggarwal <
> kamakshi...@gmail.com> wrote:
>
>> typo in above code..find t(n+1)
>>
>>
>> On Sun, Aug 14, 2011 at 12:37 AM, Kamakshii Aggarwal <
>> kamakshi...@gmail.com> wrote:
>>
>>> if steps are between banks then try dis.
>>> if n=3 steps
>>> then find t(n+2)
>>> and use the fibonacci formula t(n)=t(n-1)+t(n-2)
>>> t(1)=1;
>>> t(2)=2;
>>> now this will work ...
>>>
>>>
>>> On Sun, Aug 14, 2011 at 12:34 AM, Kamakshii Aggarwal <
>>> kamakshi...@gmail.com> wrote:
>>>
 i am sorry.i misinterpret the question...i dint c that the steps are
 between   banks..


 On Sun, Aug 14, 2011 at 12:26 AM, ankit tyagi wrote:

> seems fine..
>
>
> On Sun, Aug 14, 2011 at 12:13 AM, Mohit Goel <
> mohitgoel291...@gmail.com> wrote:
>
>> there are 5 possibilities ..5th one is_12_..other as specified by
>> ankit...
>>
>>
>> t(1) =2  (it can directly jump to anathor bank)
>> t(2) =3 ( _2_,_1_,_12_)
>>
>> t(3) =5...
>> thats how fibonnaci goes on plz correct if wrong...
>>
>>
>>  --
>> 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,
 Kamakshi
 kamakshi...@gmail.com

>>>
>>>
>>>
>>> --
>>> Regards,
>>> Kamakshi
>>> kamakshi...@gmail.com
>>>
>>
>>
>>
>> --
>> Regards,
>> Kamakshi
>> kamakshi...@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.
>>
>
>  --
> 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] manish patel wants to chat

2011-08-15 Thread manish patel
---

manish patel wants to stay in better touch using some of Google's coolest new
products.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-e026d3feed-141e1c7d4e-IcnixiONDyPSp9FJaVLNNJRPxVI
You'll need to click this link to be able to chat with manish patel.

To get Gmail - a free email account from Google with over 2,800 megabytes of
storage - and chat with manish patel, visit:
http://mail.google.com/mail/a-e026d3feed-141e1c7d4e-IcnixiONDyPSp9FJaVLNNJRPxVI

Gmail offers:
- Instant messaging right inside Gmail
- Powerful spam protection
- Built-in search for finding your messages and a helpful way of organizing
  emails into "conversations"
- No pop-up ads or untargeted banners - just text ads and related information
  that are relevant to the content of your messages

All this, and its yours for free. But wait, there's more! By opening a Gmail
account, you also get access to Google Talk, Google's instant messaging
service:

http://www.google.com/talk/

Google Talk offers:
- Web-based chat that you can use anywhere, without a download
- A contact list that's synchronized with your Gmail account
- Free, high quality PC-to-PC voice calls when you download the Google Talk
  client

We're working hard to add new features and make improvements, so we might also
ask for your comments and suggestions periodically. We appreciate your help in
making our products even better!

Thanks,
The Google Team

To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/about.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste them into
the address bar of your browser).

-- 
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] array pointer

2011-08-05 Thread Manish Sharma
1

On Fri, Aug 5, 2011 at 10:35 PM, Arshad Alam  wrote:

>
> we can equate base address of double dimension array to a pointer variable,
> tell me which one is correct. if "n" is a pointer variable and x[5][5] is
> double dimension array
>
>1. n=x;
>2. n=x[0][0];
>3. both
>
>
>  --
> 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.
>



-- 
Manish Kumar Sharma,
Undergraduate,
Computer Engg. Department.,
Netaji Subhas Institute of Technology,
New Delhi.

-- 
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-07-25 Thread Manish Kumar
suppose the array is arr[];
set index start and end at the starting and ending of the array.
 sum=arr[start]+arr[end]
check if sumvalue
decrease end index by one
and repeat the process until starthttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] C ouput

2011-07-23 Thread Manish Kumar
@Akshata:
Whenever you increase any variable then it increases according to its type.
Here the address of array 'a' is being increased.(  &a+1 ).
so the address of 'a' will temporarily increased to 20 bytes and then that
is assigned to ptr.
so ptr is now pointing to any value in the memory just after the memory
where 5 is stored.
so when we print ptr[-1] it prints "5".

I think it should be clear now.
if not,plz let me inform.

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

2011-07-19 Thread Manish Pathak
exactly archita.

On Tue, Jul 19, 2011 at 3:33 PM, archita monga wrote:

> Take 2 node pointers.Move one at the speed of twice the
> other(first:node->next,second:node->next->next) when the first pointer
> reaches the end of the list,the second will give you the middle node.
>
>
> On Tue, Jul 19, 2011 at 3:27 PM, shilpa gupta wrote:
>
>> give your algo.
>>
>>
>> On Tue, Jul 19, 2011 at 3:26 PM, SAMMM  wrote:
>>
>>> O(n) is possible . Will it serve the purpose or need less than that ???
>>>
>>> --
>>> 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.
>>>
>>>
>>
>>
>> --
>> Shilpa Gupta
>>
>> B.Tech. 3rd year
>> Computer Science and Engineering
>> 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.
>>
>
>
>
> --
> Archita Monga
>
> --
> 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 and Regards,

Manish Pathak **
TimesJobs.com
manish.pathak*@*timesgroup.com
Mo.  9015687266

-- 
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] Fwd: MICROSOFT INTERNSHIP (Coding round)

2011-07-18 Thread manish patel
let's start from top right element(call p)
if(x=0)
{   if(arr[i][j]==x)
   return 1;//found
else if(a[i][j]wrote:

>
>
> -- Forwarded message --
> From: sivaviknesh s 
> Date: Mon, Jul 18, 2011 at 11:29 PM
> Subject: Fwd: MICROSOFT INTERNSHIP (Coding round)
> To: algogeeks@googlegroups.com
>
>
>
>
> -- Forwarded message --
> From: subramania jeeva 
> Date: Thu, Sep 23, 2010 at 7:53 AM
> Subject: Re: MICROSOFT INTERNSHIP (Coding round)
> To: mitcse08i...@googlegroups.com
>
>
> Also in placement the question asked was
>
>Given a 2 dimensional matrix with its rows and columns are
> in sorted order. You've to find a number and return its positions from that
> matrix...  I think the efficient way is binary search... It'll take log(n^2)
> to the base 4.
>
> Mostly they're expecting C code rather than C++ So
> improve your C knowledge..
>
>
>
> say
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> ...say u ve to find '8'
>
> start from 1 ...check its right (2) nd down (4)
>
> 4>2 (but 4<8)so go to 4again check its right (5) nd down (7)
>
> 7>5finally reached 8 in four stepscomplexity is less than o(m*n)...
>
> ...am i rite???
>
>
>
>
>
>
>
>
> Cheers
>   ~ Jeeva ~
>
>
>
> --
> Regards,
> $iva
>
>
>
>
> --
> Regards,
> $iva
>
>  --
> 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] MICROSOFT

2011-07-17 Thread manish patel
thanx the question was asked by MS today in MNNIT.

On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal  wrote:

> take two extra arrays b[] and c[]
> in b[] store the following thing
> b[0]=1;
> b[i]=b[i-1]*a[i-1];
>
>
> in c[] store following things
> c[n-1]=1;
> c[i]=c[i+1]*a[i+1]   (i>n-1)
> fill the c[] array in reverse order i.e. start from n-1 then go to 0;
>
> now output[] would be
> output[i]=b[i]*c[i];
>
>
>
>
> On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek wrote:
>
>> given an array a[0..n-1]  .required to find the output array out
>> [0.n-1] such that out [i] is the product of all the numbers a[0] to
>> a[n-1] excluding a[i]
>> for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1]
>> constraint is not using division operator
>>
>> how to do this in O(n)??
>>
>> --
>> 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.
>>
>
>
> Anurag Aggarwal
>
>  --
> 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.
>



-- 
With Regards

Manish Patel
BTech 2nd Year
Computer Science And Engineering
National Institute of Technology -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.



Re: [algogeeks] Mouse Beer Puzzle

2011-06-28 Thread Manish Pathak
answer is 3


-- 

Thanks and Regards,

Manish Pathak **
TimesJobs.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.



[algogeeks] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread manish kapur


-- 
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-04-29 Thread Manish Kumar
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  >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.
> 

Re: [algogeeks] A SIMPLE C++ PROGRAM.

2011-04-29 Thread Manish Kumar
here
y= 1+ 3+4+4= 12
and x=5

here just follow rules of postfix and prefix operator

thanks
manish

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

2011-04-21 Thread Manish Pathak
Thank you

On Thu, Apr 21, 2011 at 8:50 PM, Rujin Cao  wrote:

> FYI.
>
> Someone is starting to translate the Chinese version in
> http://pro.yeeyan.org/CRACKINGTHECODINGINTERVIEW
>
>
> 2011/4/21 LALIT SHARMA 
>
>> Please mail me 2 ,
>>
>> my id is lks.ru...@gmail.com
>>
>> thnX in Advance ..
>>
>> On Thu, Apr 21, 2011 at 12:45 PM, kamlesh yadav 
>> wrote:
>> > can anyone give me  list of books  like ( cracking the coding
>> > interview )
>> >  for placement preparation
>> >
>> > 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.
>> >
>> >
>>
>>
>>
>> --
>> Lalit Kishore Sharma,
>> IIIT Allahabad (Amethi Capmus),
>> 6th Sem.
>>
>> --
>> 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 and Regards,

Manish Pathak **
TimesJobs.com
Mo.  9015687266

-- 
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: Finding non-repetitive element from an Array with complexity n

2011-04-17 Thread Manish Pathak
I think ,Gunjan's solution is right.


suppose  {1,2,1,3,2} is given,
1  ---  01
2    10
3  -  11
..
..
..

So XOR these elements   01  XOR  10  ---> 11
  11 XOR  01   ---> 10
   10 XOR 11   --->  01
   01 XOR 10   --->  11(3)


So answer is 3.
Any query???
-- 

Thanks and Regards,

Manish Pathak **
TimesJobs.com
Mo.  9015687266

-- 
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] Permutation of a string

2011-04-08 Thread Manish Pathak
 #include 
#include 
#include 
int fact(int n);
void main()
{
char a[20],st_char;
static int i,j,k,n,ctr,main_ctr;
printf("Enter the string : ");
//gets(a);
scanf("%s",a);

n=strlen(a);

if(n<=1)
{
printf("please enter a valid string ");
exit(0);
}

//label :
while(main_ctr>>>>Designed by Manish Pathak<<<<<<<< ");
}

-- 
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 ] 1april

2011-04-06 Thread Manish Pathak
Hi kamakshi
  I think, kusum answer's is right, can u explain why A
not???


-- 

Thanks and Regards,

Manish Pathak **
TimesJobs.com
Mo.  9015687266
 *http://manishpathak-mobile.blogspot.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.



Re: [algogeeks] Re: 28march

2011-04-06 Thread Manish Pathak
There are two answers

11 and   7

On Thu, Mar 31, 2011 at 12:23 PM, Abhishek Sharma wrote:

> @sourabh: could u please elaborate how u came to that conclusion.
> Dave's logic seems to be right..
>
> On Thu, Mar 31, 2011 at 11:00 AM, sourabh jakhar 
> wrote:
>
>> answer is 6 races
>>
>>
>>
>> On Mon, Mar 28, 2011 at 11:53 PM, Dave  wrote:
>>
>>> 7 races.
>>>
>>> For the first five races, divide the horses into groups of five and
>>> record the win, place, and show finishers of each race.
>>>
>>> For the sixth race, run the winners of the first five races.
>>>
>>> Now, only six horses remain in contention for the fastest three:
>>>   The winner of the sixth race and the place and show horses of his
>>> first race,
>>>   The place horse in the sixth race and the place horse in his first
>>> race.
>>>   The show horse in the sixth race.
>>>   Three of these horses are known to be faster than all other horses.
>>>
>>> The winner of the sixth race is known to be the fastest horse. Run the
>>> other five contenders in race 7 and choose the fastest two.
>>>
>>> Dave
>>>
>>> On Mar 28, 2:54 am, Lavesh Rawat  wrote:
>>> > *Horse Race Problem Solution*
>>> > *
>>> > *Ok, so there are 25 horses and the race track only allows 5 horses to
>>> race
>>> > at a given time. Given that there is no stop watch available your task
>>> is to
>>> > determine the fastest 3 horses. Assume that each horses speed is
>>> constant in
>>> > different races, what is the minimum number of races to determine the
>>> > fastest 3?
>>> >
>>> > Update Your Answers at : Click
>>> > Here<
>>> http://dailybrainteaser.blogspot.com/2011/03/28march.html?lavesh=lavesh>
>>> >
>>> > 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.
>>>
>>>
>>
>>
>> --
>> 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.
>>
>
>  --
> 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 and Regards,

Manish Pathak **
TimesJobs.com
Mo.  9015687266
 http://manishpathak-mobile.blogspot.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.



Re: [algogeeks] brain teaser

2011-03-03 Thread Manish Pathak
I think that the last person will tell the color of next front person of
him, that means next person will sure that his hat color will be color
,telling by back person.
thus person 19 ,17,15,13,11,9,7,5,3,1 th position will get free,and rest amy
or may not be...

if i am wrong ,tell me


On Thu, Mar 3, 2011 at 1:48 PM, freecoder  wrote:

> You are one of 20 prisoners on death row with the execution date set
> for tomorrow.
>
> Your king is a ruthless man who likes to toy with his people's
> miseries. He comes to your cell today and tells you:
>
> “I’m gonna give you prisoners a chance to go free tomorrow. You will
> all stand in a row (queue) before the executioner and we will put a
> hat on your head, either a red or a black one. Of course you will not
> be able to see the color of your own hat; you will only be able to see
> the prisoners in front of you with their hats on; you will not be
> allowed to look back or communicate together in any way (talking,
> touching.)
>
> (The prisoner in the back will be able to see the 19 prisoners in
> front of him
> The one in front of him will be able to see 18…)
>
> Starting with the last person in the row, the one who can see
> everybody in front of him, he will be asked a simple question: WHAT IS
> THE COLOR OF YOUR HAT?
>
> He will be only allowed to answer “BLACK” or “RED”. If he says
> anything else you will ALL be executed immediately.
>
> If he guesses the right color of the hat on his head he is set free,
> otherwise he is put to death. And we move on to the one in front of
> him and ask him the same question and so on…
>
> Well, good luck tomorrow, HA HA HA HA HA HA!”
>
> Now since you all can communicate freely during the night, can you
> find a way to guarantee the freedom of some prisoners tomorrow? How
> many?
>
> --
> 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 and Regards,

Manish Pathak **
TimesJobs.com
manish.pat...@timesgroup.com
Mo.  9015687266

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

2011-03-03 Thread Manish Pathak
Explain @Param explain it..

On Thu, Mar 3, 2011 at 11:34 AM, preetika tyagi wrote:

> @Arpit - Can you please explain how would you solve it using binary search?
>
>
> On Wed, Mar 2, 2011 at 10:41 PM, Arpit Sood  wrote:
>
>> O(logn) binary search if there are no duplicates, else O(n)
>>
>>
>> On Thu, Mar 3, 2011 at 11:04 AM, Param10k  wrote:
>>
>>> There is a sorted array and you have to write a fn to find a number in
>>> the array which satisfies
>>>
>>> A[i] = i ; where A is the array and i is the index...
>>>
>>> - Param
>>> http://teknotron-param.blogspot.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.
>>>
>>>
>>
>>
>> --
>> Regards,
>> Arpit Sood
>>
>>  --
>> 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 and Regards,

Manish Pathak **
TimesJobs.com
Mo.  9015687266

-- 
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] MINIMUM POSITIVE SUM

2011-02-09 Thread Manish Verma
Given: An array of integers(may be both positive and negative), we
have to find out the  minimum positive sum of array(not necessarily
continuous).

example:-  {1,-5,7,10,-14,16,-17,20,21,22}

here answer is -5,-17,22 having sum=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.



[algogeeks] Re: c programming question

2011-02-05 Thread Manish Verma

i think juver has explained
On Feb 5, 9:34 pm, jagannath prasad das  wrote:
> @manish:can you explain with the example of a specific compiler...
>
> On Sat, Feb 5, 2011 at 10:02 PM, jagannath prasad das
> wrote:
>
>
>
> > @ankit:ans is 22 13 14 14 in gcc compiler.
>
> > On Sat, Feb 5, 2011 at 7:24 PM, Manish Verma wrote:
>
> >> answer will depend on your compiler.
>
> >> On Feb 5, 1:02 am, jagannath prasad das  wrote:
> >> > *#include
> >> > void main(void)
> >> > {
> >> > int a=10,b;
> >> > b=a++ + ++a;
> >> > printf("%d,%d,%d,%d",b,a++,a,++a);
>
> >> > }
>
> >> > *what is the answer?how are the function parameters passed on the stack?
>
> >> --
> >> 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: c programming question

2011-02-05 Thread Manish Verma
answer will depend on your compiler.

On Feb 5, 1:02 am, jagannath prasad das  wrote:
> *#include
> void main(void)
> {
> int a=10,b;
> b=a++ + ++a;
> printf("%d,%d,%d,%d",b,a++,a,++a);
>
> }
>
> *what is the answer?how are the function parameters passed on the stack?

-- 
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] Please check it out

2010-12-04 Thread Manish Pathak
#include
void main()
{
int a[]={0,1,1,1,1,1,0,0,0,0,0,1},i=0;
static int o=0,e=0;//e for no. of 1's in array and o means no. of 0 in array
int l=sizeof(a)/4;
while(io)   //if n0. of 1's greater than no. of 0's then e=o
e=o;
for(i=0;i<(e*2);i++)
{
a[i]=i%2;
}
for(i=e*2;ie)
a[i]=0;
else if(e>o)
a[i]=1;
}


for(i=0;ihttp://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] google

2010-10-14 Thread Manish K
Hi,

Take an example :

Array A: {a1,a2,a3,a4,a5}- (sorted decreasingly)

Array B :{b1,b2,b3,b4,b5}- (sorted decreasingly)

First pair is(a1,b1) .

Now for Second pair Compare the sum of (b1,a2) and (a1,b2) whichever is
greater .
if (a1,b2) is the  second pair  then now compare (b1,a2) and (a1,b3) .

Repeat the above process till u will get first n pairs.
Complexity O(n).


Thanks
Manish

On Thu, Oct 14, 2010 at 3:24 PM, arun raghavendar wrote:

> Start merging A and B from the tail end for N elements, just like the way
> you would do it for a merge sort but with a different constraint based on
> the sum a[i] and b[i]
>
> This should work for any value of N, I just hard-coded it for simplicity.
>
>
> #include
> #define N 6
> struct OutputType {
> int a;
> int b;
> int value;
> };
>
> int main() {
> int a[N] = {1,8,13,24,25,30};
> int b[N] = {5,6,17,28,29,29};
> struct OutputType s[N];
> int i, a_candidate_1 = N-1, a_candidate_2=N-2, b_candidate_1=N-1,
> b_candidate_2=N-2;
> s[0].a = a[N-1];
> s[0].b = b[N-1];
> s[0].value = a[N-1] + b[N-1];
> for (i=1;i if ((a[a_candidate_1]+b[b_candidate_2]) >=
> (a[a_candidate_2]+b[b_candidate_1])) {
> s[i].a = a[a_candidate_1];
> s[i].b = b[b_candidate_2];
> s[i].value = a[a_candidate_1]+b[b_candidate_2];
> b_candidate_2--;
> if (b_candidate_2 < 0) { a_candidate_1--; }
> } else {
> s[i].a = a[a_candidate_2];
> s[i].b = b[b_candidate_1];
> s[i].value = a[a_candidate_2]+b[b_candidate_1];
> a_candidate_2--;
> if (a_candidate_2 < 0) { b_candidate_1--; }
> }
> }
>
> for (i=0;i%3d ", s[i].a, s[i].b,
> s[i].value);
>
> return 0;
> }
>
>
> -Arun
>
>
> On Thu, Oct 14, 2010 at 1:25 PM, Harshal  wrote:
>
>>
>> Given two sorted postive integer arrays A[n] and B[n] (W.L.O.G, let's
>>
>>
>> say they are decreasingly sorted), we define a set S = {(a,b) | a \in A
>> and b \in B}. Obviously there are n^2 elements in S. The value of such
>> a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
>>
>>
>> from S with largest values. The tricky part is that we need an O(n)
>> algorithm.
>>
>>
>> --
>> Harshal Choudhary,
>> III Year B.Tech Undergraduate,
>> Computer Engineering Department,
>> National Institute of Technology Surathkal, Karnataka
>> India.
>>
>>  --
>> 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.
>

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

2010-07-28 Thread manish bhatia
I guess your solution would also be proved incorrect with the following,

Numbers in bold are the two arrays.

  125 122 120 110 104 103 102 101 
100 999897 


130255 252 250 240 234 233 232 231 230 
229 228 227 
128   253 250 248 238 232 231 230 229 228 
227 226 225
126   251 248 246 236 230 229 228 227 226 
225 224 223
125   250 247 245 235 229 228 227 226 225 
224 223 222
105   230 227 225 215 209 208 207 206 205 
204 203 202
104229 226 224 214 208 207 206 205 204 
203 202 201
103228 225 223 213 207 206 205 204 203 
202 201 200
102227 224 222 212 206 205 204 203 202 
201 200 199
101226 223 221 211 205 204 203 202 201 
200 199 198
100   225 222 220 210 204 203 202 201 200 
199 198 197
99 224 221 219 209 203 202 201 200 199 
198 197 196
98 224 221 219 209 203 202 201 200 199 
198 197 196

 manish...





From: Varun Nagpal 
To: Algorithm Geeks 
Sent: Mon, 3 May, 2010 12:26:24 PM
Subject: Re: [algogeeks] Re: a google question

Guys no one commented on my solution? Any takes on it?


Anyways, below is my solution (in pseudo code)

Pre-condition: A and B are sequences of equal length and sorted in
descending order
Input: Sequences A[1..N] and B[1..N] of equal lengths(N)
Ouput: Sequence C[1..N] containing sorted sum of ordered pairs from
cartesian products of A, B or B,A

Sort(A,B)
{
k = 1
N = length(A) = length(B)
C[1..2*N] = []// Empty array
cart_prod_order = 0   // 0 -> AxB, 1 -> BxA. 0 is default

// Complexity : O(N)
while(k != N+1)
{
   if (A[k] < B [k])
   {
cart_prod_order = 1
break
   }
   else
   {
k = k + 1
   }
}

// Choose the correct order of Cartesian product sum
// Complexity: Theta(2N) = O(N)
if (cart_prod_order == 1)
{
// take cartesian product of B and A, storing the sum of ordered
pair (b,a) in each element of C
C[1..2N] = B[1..2] x A[1..N]
}
else
{
   // take cartesian product of A and B, storing the sum of ordered
pair (a,b) in each element of C
   C[1..2N] = A[1..2] x B[1..N]
}

// Merge
// C[1..N] and C[N+1..2N] are already sorted in descending order
// Complexity: Theta(N)
C[1..2N] = Merge(C[1..N],C[N+1..2N])

return C[1..N]
}

Merge(C,D)
{
i=1,j=1,k=1
E = []
while(i<=length(C) OR j<=length(D))
{
   if(i<=length(C) AND (j>length(D) OR C[i]>D[j]))
   {
E[k] = C[i]
i = i + 1
   }
   else
   {
E[k] = D[j]
j = j + 1
   }
   k = k + 1
}

return E;
}

On Fri, Apr 30, 2010 at 7:50 PM, banu  wrote:
> Nice question:
>
> 1. |A| = |B| i.e I assume their cardinality is equal
>
> 2. A(n) = { a1, a2  a3, ...aN} such that a1>=a2>=a3...>=aN
> 3. B(n) = { b1, b2  b3, ...bN} such that b1>=b2>=b3...>=bN
>
> 4. S(n^2) = A x B = {(a1,b1), (a1,b2)(a1,bN),
>  (a2,b1), (a2,b2)(a2,bN),
>   
>  (aN,b1), (aN,b2)(aN,bN)}
>
>  assuming we have added in a way such that we find a pair  ai > bi,
> for some i in 1..N such that a(i-1) = b(i-1)
>
> A first observation is that in the worst case, the first 2N numbers in
> S will contain the final result of N numbers.
> i.e in  (a1,b1), (a1,b2)(a1,bN), (a2,b1), (a2,b2)(a2,bN)
>
> In the best case first N numbers in S will contain the final N numbers
> (already sorted in decreasing order)
> i.e in  (a1,b1), (a1,b2)(a1,bN)
>
> Now, if we consider again the worst case scenario, then we can first
> divide 2N numbers in two groups of size N each and each of this group
> is already sorted in decreasing order.
> i.e  (a1,b1), (a1,b2)(a1,bN) and (a2,b1), (a2,b2)(a2,bN)
>
> Now we can simply apply Merge Algorithm on these 2 already sorted
> arrays of size N each in O(N) time, which solves the problem
>
> I can be wrong only if the the results lie outside first 2N
> numbers(which I hope is not the case).
>
>
> On Apr 30, 2:05 pm, divya  wrote:
>> Given two sorted postive integer arrays A(n) and B(n) (W.L.O.G, let's
>> say they are decreasingly sorted), we define a set S = {(a,b) | a \in
>> A
>> and b \in B}. Obviously there are n^2 elements in S. The value of such
>> a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
>> from S with largest values. The tricky pa

Re: [algogeeks] a google question

2010-07-26 Thread manish bhatia
How are we making sure that top n-elements would lie in this 'L' shaped array?

Also, why don't we take an extreme case, such that the origin is bottom-left 
element of the grid, then we have only 2n-1 elements to chose n biggest 
elements 
from.

So, can we prove that taking Ist quardrant as (n-2)x(n-3) would leave n-biggest 
out? What is the criterion to chose the Ist quardrant?

 manish...





From: topojoy biswas 
To: algogeeks@googlegroups.com
Sent: Thu, 22 July, 2010 10:10:58 AM
Subject: Re: [algogeeks] a google question

im sry the L should look like this:



   109  8 5 321
7 17   16
8 18   17
9 19   18
10   20   19
11   21   2019   1614  13 12
12   22   2120   1715  14  13
13   23   2221   1816  15  14


I missed a row in the last mail.


On Thu, Jul 22, 2010 at 10:03 AM, topojoy biswas  
wrote:

consider these arrays:
>
>10 9 8 5 3 2 1
>
>and 
>
>13 12 11 10 9 8 7
>
>
>form a grid like this:
>
>   109  8 5 321
>7 17   1615   1210  98
>8 18   1716   1311  10  9
>9 19   1817   1412  12 10
>10   20   1918   1513  12 11 
>11   21   2019   1614  13 12
>12   22   2120   1715  14  13
>13   23   2221   1816  15  14
>
>basically have an array descending and have one array ascending. 
>
>If you add them in a grid, check that for any sum, all sums to its right are 
>less than it( in the same row), al sums above it( in the same column) are less 
>than it, all sums below it( in the same row) are greater than it.
>
>   109  8 5 321
>7 17   1615   1210  98
>8 18   1716   1311  10  9
>9 19   1817   1412  12 10
>10   20   1918   1513  12 11 
>11   21   2019  1614  13 12
>12   22   2120   1715  14  13
>13   23   2221   1816  15  14
>
>So all sums which form the first quadrant origining at 19 are less than 19.
>
>And the 3rd quadrant formed by origining 19 including 19 are strickedly grater 
>than or equal to 19. 
>
>
>This means in the added array will look like this:
>__
>||___|__|
> <---x--><--m---><-y->
>
>x = no of elements in the underlined first quadrant
>y= no of elements in the 3rd quadrant excluding 19.
>m= the number of elements in the 2nd and the 4th quadrant including 19.
>
>So 19 would lie some whr in the 2n slot of this divided aray picture.
>
>So if we make x big enough so that m+y is small enough=O(n), we will reduce 
>our 
>load.
>
>so choose x=(n-2)(n-3) which means something like this:
> <--(n-2)--->
>   109  8 5 321
>7 17   1615   1210  98   ---
>8 18   1716   1311  10  9   
>9 19   1817   1412  12 10 (n-3)
>10   20   1918   1513  12 11   -
>11   21   2019   1614  13 12
>12   22   2120   1715  14  13
>13   23   2221   1816  15  14
>
>Then we will be left with an array of size m+y=5n-6 which is >n for all n >2 
>like this:
>
>   109  8 5 321
>7 17   16
>8 18   17
>9 19   18
>10   20   19
>11   21   20
>12   22   2120   1715  14  13
>13   23   2221   1816  15  14
>
>Till this point it takes constant time.
>
>Now the first column of the "L" formed is sorted. So is the 2nd column.
>
>So is the horizonal part of L which is comprized of two sorted arays (20-13) 
>and 
>(21-14).
>
>All of the elements add to 5n-6. We can merge sort them in O(n) time. Take the 
>biggest n elements.
>
>
>
>
>
>
>On Mon, Jul 19, 2010 at 12:18 PM, ankur aggarwal  
>wrote:
>
>
>>
>>
>>this ques was asked by google.. i* could find any gud soln than order n*n
>>>
>>>
>>>
>>
-- 
>>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.
>>
>
>
>-- 
>Topo.
>
>There are days when solitude is a heady wine that intoxicates you with 
>freedom, 
>others when it is a bit

Re: [algogeeks] a google question

2010-07-19 Thread manish bhatia
Given two sorted postive integer arrays A(n) and B(n) (W.L.O.G, let's
say  they are decreasingly sorted), we define a set S = {(a,b) | a \in
A
and  b \in B}. Obviously there are n^2 elements in S. The value of such
a  pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
from  S with largest values. The tricky part is that we need an O(n)
algorithm.
 manish...





From: Ashish Goel 
To: algogeeks@googlegroups.com
Sent: Sun, 18 July, 2010 6:31:08 PM
Subject: Re: [algogeeks] a google question

question please...

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



On Fri, Jul 16, 2010 at 4:43 PM, manish bhatia  wrote:

It doesn't work
>
>A =>
>92 87 81 72 70 61 53 22 18 17
>
>B =>
>79 78 74 68 64 62 57 34 29 24
>
>C (GOLD) =>
>171 170 166 166 165 161 160 160 159 156
>
>D (TEST) =>
>171 170 166 166 165 159 155 155 146 145
>
>Result: FAILED!
>
>
> manish...
>
>
>
>
>

From: Jitendra Kushwaha 
>To: algogeeks@googlegroups.com
>Sent: Sun, 2 May, 2010 9:13:14 PM
>Subject: Re: [algogeeks] a google question
>
>Here is a solution of O(n)  , taking 4 pointers 2 for each array
>
>
>#include 
>#include
>using namespace std;
>
>#define N 10
>
>int main(void)
>{
>int arr1[N] = {8,7,4,3,2,1,1,1,1,1};
>int arr2[N] = {34,23,21,19,15,13,11,8,4,2};
>int *p11,*p12,*p21,*p22;
>p11 = p12 = arr1;
>p21 = p22 = arr2;
>int f1;
>f1 = 0;
>
>for(int i=0;iint ans=0;
>int a,b,c,d;
>a = *p11 + *p21;
>b = *p11 + *p22;
>c = *p21 + *p12;
>d = *(p11+1) + *(p21+1);
>
>//printf("a=%d b=%d c=%d d=%d\n",a,b,c,d); //debug
>
>if(f1==0)ans = a  ,p12++ , p22++ , f1=1;  
>
>else if(b >= c && b >= d )ans = b  , p22++ ;
>
>else if(c >= b && c >= d )ans = c , p12++ ;
>
>elseans = d , p11++ , p21++ ,printf("4 ");
>
>printf("%d\n",ans);
>}
>}
>
>
>Regards
>Jitendra Kushwaha
>Undergradute Student
>Computer Science & Eng.
>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 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.
>

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



Re: [algogeeks] a google question

2010-07-16 Thread manish bhatia
It doesn't work

A =>
92 87 81 72 70 61 53 22 18 17

B =>
79 78 74 68 64 62 57 34 29 24

C (GOLD) =>
171 170 166 166 165 161 160 160 159 156

D (TEST) =>
171 170 166 166 165 159 155 155 146 145

Result: FAILED!


 manish...





From: Jitendra Kushwaha 
To: algogeeks@googlegroups.com
Sent: Sun, 2 May, 2010 9:13:14 PM
Subject: Re: [algogeeks] a google question

Here is a solution of O(n)  , taking 4 pointers 2 for each array


#include 
#include
using namespace std;

#define N 10

int main(void)
{
int arr1[N] = {8,7,4,3,2,1,1,1,1,1};
int arr2[N] = {34,23,21,19,15,13,11,8,4,2};
int *p11,*p12,*p21,*p22;
p11 = p12 = arr1;
p21 = p22 = arr2;
int f1;
f1 = 0;

for(int i=0;i= c && b >= d )ans = b  , p22++ ;

else if(c >= b && c >= d )ans = c , p12++ ;

elseans = d , p11++ , p21++ ,printf("4 ");

printf("%d\n",ans);
}
}


Regards
Jitendra Kushwaha
Undergradute Student
Computer Science & Eng.
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 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] Re: Finding the middle of a singly linked list which has a cycle in it

2010-03-29 Thread Manish
@Umer: I guess the last node in the LL is _not_ pointing to the head
back. Rather, its pointing to one of the intermediate nodes. That way,
N2 or N2.next might not ever be _head_. See example: 1->2->3->4->5->3,
where the last node points to the 3rd node in LL.



On Mar 29, 9:21 pm, Umer Farooq  wrote:
> that's why i have a terminating condition. It will keep on iterating until
> ((N2 != head)&&(N2->NextPtr != head)) is true.
>
> head pointer of the linked list will be passed as an argument to the
> function.
>
> On Mon, Mar 29, 2010 at 7:04 AM, Navin Naidu  wrote:
> > @Umer: Its a singly LL and it has cycle. Both N1 and N2 will keep
> > traversing within the cycle.
>
> > On Sun, Mar 28, 2010 at 9:56 PM, Umer Farooq  wrote:
>
> >> I'll appreciate comments on the solution proposed by me. It works the
> >> following way:
>
> >> take two pointers, N1 and N2 pointing on the head of the list.
>
> >> Move N2 by two nodes, and N1 by a single node.
>
> >> When N2 reaches head again (or N2->Next is a head)
>
> >> then return N1 which will be pointing to the middle element of the list.
>
> >> Regards
> >> Umer Farooq
>
> >> On Sun, Mar 28, 2010 at 2:17 PM, Mukesh Kumar thakur <
> >> mukeshraj8...@gmail.com> wrote:
>
> >>> hi! in my opinion we can find the middle element in the singly linked
> >>> which hv the cycle
> >>> as we know the list doesnt support the concept of cycle coz it has only
> >>> one direction traversal
>
>  but if we take the case when the list hvng  the no of element equal
>
> >>> as we hv :
> >>>                      n element in the list
> >>> we hv to find the middle one
> >>>     in genral;simply we divide it in .
> >>> n/2; or
> >>> if consider middle elment as a key 
> >>>          temp->link=null;
> >>>           temp->first=middle
>
> >>> --
> >>> 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.
>
> > --
> > Thanks & Regards,
> > NMN
>
> >  --
> > 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] Re: Largest span of Increasing Pair in an array

2010-03-22 Thread Manish
This does not look like a solution for the posted problem.
This fails the test case {2, 7, 6, 0, 100}, where the answer should
have been 4, for k=0 and j=4.

Manish

On Mar 20, 1:49 pm, saurabh gupta  wrote:
> This may not be the optimal solution to
> " Given an array of integers A[N], find the maximum value of (j-k) such
> that A[k] <= A[j] & j>k.
> I am looking for a solution with time complexity better than O(N^2)."
>
> this was in response to
> "how u can solve it in o(n)"
> and
> "how to solve this in the claimed  O(N) time."
>
>
>
> On Sat, Mar 20, 2010 at 9:14 PM, Ralph Boland  wrote:
>
> > On Mar 15, 10:07 am, saurabh gupta  wrote:
> > > while you scan the array
> > > maintain four indices plus two lengths
> > > two indices and a length mark one sub-array - start,end, length
> > > each such sub-array indicates a non-decreasing sequence,
> > > call them S1 and S2.
>
> > > while one scans, S2 keeps track of incoming elements (curr sequence)
> > > S1 keeps track of the maximum length (along with indices) so far (prev
> > > sequence)
> > > as one encounters an element which is less than the previous element,
> > > this marks the end of S2,
> > > S1 replaces S2 if len S2 > len S1 else S2 starts afresh from this new
> > > element.
>
> > > In the end if len S2 > len S1 answer = S2
> > > else answer = S1.
>
> > > PS: In the beginning and till one encounters a smaller element  than the
> > > prev one for the first time, S1 = S2
>
> > I agree that this is a nice algorthithm that solves the
> > largest non decreasing  sequence problem.
> > However, I don't agree that this solves the problem
> > originally posted.
>
> > Regards,
>
> > Ralph Boland
>
> > --
> > 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.
>
> --
> Man goes to doctor. Says he's depressed. Says life seems harsh and cruel.
> Says he feels all alone in a threatening world where what lies ahead is
> vague and uncertain. Doctor says "Treatment is simple. Great clown
> Pagliacci is in town tonight. Go and see him. That should pick you up." Man
> bursts into tears. Says "But, doctor...I am Pagliacci."

-- 
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: random number...

2009-09-28 Thread manish bhatia
How are you picking ni from [a...b] range (length 7) ?





From: avalon 
To: Algorithm Geeks 
Sent: Saturday, 19 September, 2009 2:16:47 PM
Subject: [algogeeks] Re: random number...


Forgive me first if i am wrong since i didn't read all the posting ...
Here is a way to sol the problem.

n1 = random_1_5() + 0;
n2 = random_1_5() + 5;
..
n7= random_1_5() + (7-1)*5;

now n1 ... n7  is in range [1 ... 35]
Image we divde the range [1.. 35] into 5 parts, such as [1...7] ,
[8...14] ...

then we generat n8 = random_1_5()
we use n8 to pick a part we divided above.
so we get a range [a...b] , then we can get a number ni inside the
range,
return ni;

ankur aggarwal  wrote:
>   Given a random number generator that generates numbers in the range 1 to
> 5, how can u create a random number generator to generate numbers in the
> range 1 to 7. (remember that the generated random numbers should follow a
> uniform distribution in the corresponding range)



  Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew
--~--~-~--~~~---~--~~
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] selection from infinite tape

2009-09-17 Thread manish bhatia
There is an infinite tape running, churning out numbers. You are able to see 
these numbers one by one, but not allowed to store all of them, but you should 
be ready with k numbers whenever prompted, such that all have been selected 
with equal probability. Say, when you were prompted, n numbers have already 
passed, each of your selected k numbers should have 1/n as the selection 
probablity. 

Of course, you can store k numbers from that tape as the tape is progressing, 
so that you can present them when prompted.


  Now, send attachments up to 25MB with Yahoo! India Mail. Learn how. 
http://in.overview.mail.yahoo.com/photos
--~--~-~--~~~---~--~~
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: max product of any three nos in an array of signed integers

2009-09-16 Thread manish bhatia


This one is better than what I suggested before. Doable in O(n)!

On Sep 13, 10:10 pm, Dave  wrote:
> The following assumest that n >= 5. Find the 3 largest positive
> numbers and the two largest-in-magnitude negative numbers (i.e., the
> two smallest signed numbers).
>
> If there are not two negative numbers, the 3 largest positive numbers
> are the answer.
>
> Otherwise, if there are only one or two positive numbers, the largest
> positive number and the two largest-in-magnitude negative numbers are
> the answer.
>
> Otherwise, compare the product of the three largest positive numbers
> with the product of the largest positive number and the two largest-in-
> magnitude negative numbers. The answer is whichever set produces the
> largest product.
>
> If the product of the answer set is zero, the answer will not be
> uniquely determined.
>
> This can be done in O(n) time and O(1) extra space.
>
> Dave
>
> On Sep 13, 8:34 am, SP Praveen  wrote:
>
> > Given an array of integers (signed integers), find three numbers in
> > that array which form the maximum product.



  Try the new Yahoo! India Homepage. Click here. http://in.yahoo.com/trynew
--~--~-~--~~~---~--~~
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: max product of any three nos in an array of signed integers

2009-09-16 Thread manish bhatia
1. Sort the array (say arr) (O(nlgn)
2. Find the position of 0 in the array. The left of the array would be all -ve 
and right of the array is all positive. Say zi is the position of zero, so 
indices [0, zi) are all -ve and (zi, n-1] are all +ve. (O(lgn). If 0 is not 
there in the array, we can still find its position, say it is b/w ith and 
(i+1)th index. Then the -ve array would be with indices [0, i], and +ve array 
would be (i, n-1].
3a. if(zi == n-1)  // arr contains -ve elements only
  return arr[0]*arr[1]*arr[2];
3b. if(zi == 0) // arr contains +ve elements only
  return arr[n-1]*arr[n-2]*arr[n-3];
3c. return max{arr[n-1]*arr[n-2]*arr[n-3], arr[n-1]*arr[zi-1]*arr[zi-2]};

Only other cases remaining are boundry conditions, for e.g. if -ve array size 
is 1, or when +ve array size is < 3.

So seems doable in O(nlgn + lgn).





From: SP Praveen 
To: Algorithm Geeks 
Sent: Sunday, 13 September, 2009 7:04:37 PM
Subject: [algogeeks] max product of any three nos in an array of signed integers


Given an array of integers (signed integers), find three numbers in
that array which form the maximum product.



  Now, send attachments up to 25MB with Yahoo! India Mail. Learn how. 
http://in.overview.mail.yahoo.com/photos
--~--~-~--~~~---~--~~
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: N number apples needs to distribute across M num baskets of varying capacity in balanced way

2009-09-09 Thread manish bhatia
How about the following,

No. of apples = N
No. of baskets = M
Capacity of baskets = [C1, C2, , Cm]

P = capacity utilization = N/(C1 + C2 + ... + Cm)

Apples in i'th basket = Ci*P

Of course (Ci*P) need not be integeral. Perhaps we can try rounding it to 
nearest integer and see if their some equals N. If not, start trying different 
combinations, but try to be as close to Ci*P as possible.


 


From: Sandeep .A.S. 
To: algogeeks@googlegroups.com
Sent: Wednesday, 9 September, 2009 4:52:13 PM
Subject: [algogeeks] Re: N number apples needs to distribute across M num 
baskets of varying capacity in balanced way


Hello Bharath,

Thanks for your suggestion.

I want to distribute the apple across all the basket balanced way.
In other words
“I want to calculate the optimal number of apples on each basket  such
a  way that free and used space on each basket  equal to total
percentage of free and used space on all the baskets “

Thanks & Regards,
Sandeep


On 9/9/09, Bharath Kumar  wrote:
> What does optimal balance mean?
>
> In your example case, if you have 10 apples,
>
> put 2 in basket1, 4 in basket2, 4 in basket3 and basket4 gets nothing.
>
> If you have to make sure that, each basket gets at least one apple, then
> start distributing apples one by one to each basket until it reaches its max
> capacity.
>
> But approach may differ upon the definition of optimality.
>
>
>
> On Wed, Sep 9, 2009 at 11:54 AM, Sandeep .A.S. 
> wrote:
> >
> > Hi,
> >
> > Please let me know is there any standard algorithm to solve the below
> > mentioned problem.
> >
> > Problem statement:
> >
> > I am having 10 apples and 4 basket each basket capacity is as mentioned
> below:
> >
> > Basket1 : capacity can hold  maximum of 2 apples
> > Basket2 : capacity can hold maximum  of 4 apples
> > Basket3 : capacity can hold maximum  of 6 apples
> > Basket4 : capacity can hold maximum  of 8 apples
> >
> > I want to distribute the apples based on percentage contribution of
> > each basket to total number of apples can accommodate by all the
> > basket
> >
> > For the above example the 10 apples can be distributed as follows:
> >
> > 1 apple for basket1 (10% => (/< total of all basket
> > capacity>) *100 => (2/20) *100)
> > 2 apple for basket1(20% =>(/< total of all basket
> > capacity>) *100 => (4/20) *100)
> > 3 apples for basket 3(30% => (/< total of all basket
> > capacity>) *100 => (6/20) *100)
> > 4 apples for basket 4(40% => (/< total of all basket
> > capacity>) *100 => (8/20) *100)
> >
> > In the above example what if I have 13 apples?  What is the best
> > approach to solution which is near to optimal balance?
> >
> > I request you to provide the idea to resolve this problem.
> >
> > Thanks &  Regards,
> > Sandeep
> >
> >
> >
>
>
>
> --
> <>
>
>
> >
>



  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: random number...

2009-09-09 Thread manish bhatia
Dave,

You are correct about the first approach. It is biased towards '1' and of 
course 000 goes waste.

With the second approach, I couldn't find a uniform distribution, because there 
is no power of 5 which is a multiple of 7, as they are relatively prime. For 
the errornous approach where 1 transition goes waste, code should be very 
simple. Here is a prototype,

int rand_1_7() {
 int f = 15624/7;
    // since transitions are already random, lets divide 15624 uniformly for 
each of 1,2,..,7
    // lets imagine a number with base 5, so 15625 is 100, and 15624 will 
be 44.
   // suppose each call to rand_1_5() gives one bit for the number
   int b1 = rand_1_5()-1; // 1 is substracted to bring the numbers to the range 
[0,4]
   int b2 = rand_1_5()-1;
   int b3 = rand_1_5()-1;
   int b4 = rand_1_5()-1;
   int b5 = rand_1_5()-1;
   int b6 = rand_1_5()-1;
   
   int num = (5^5)*b6 + (5^4)*b5 + (5^3)*b4 + (5*2)*b3 + (5^1)*b2 + (5^0)*b1;
   
   if(num <= f) return 1;
   if(num <= 2*f) return 2;
   if(num <= 3*f) return 3;
   if(num <= 4*f) return 4;  
   if(num <= 5*f) return 5;
   if(num <= 6*f) return 6;
   return 7;
}


From: Dave 
To: Algorithm Geeks 
Sent: Wednesday, 9 September, 2009 2:42:26 AM
Subject: [algogeeks] Re: random number...


Manish, your first approach doesn't work. You will notice that b1, b2,
and b3 each are 0 2/5 of the time and 1 3/5 of the time, so the return
value is not uniformly distributed.

For approach 2, what do you have to do if you want an exactly uniform
distribution as a result? Or what would the code look like for one of
your non-exact methods?

Dave

On Sep 8, 1:32 pm, manish bhatia  wrote:
> I can think of 2 appraches.
>
> [1] Similar to something already suggested. Just adding my 2 cents.
>
> 1 to 7 digits can be represented by 3 bits. So going by that,
>
> int rand_1_7() {
>  b1 = rand_1_5()*(7/5) > (7/2) ? 1 : 0;
>  b2 = rand_1_5()*(7/5) > (7/2) ? 1 : 0;
>  b3 = rand_1_5()*(7/5) > (7/2) > 1 : 0;
>  return (b1*4 + b2*2 + b3*1);
>
> }
>
> [2] What we are trying to do is map numbers 1 to 5 to numbers 1 to 7. Of 
> course mapping 5 items to 7 items is not straight forward. So lets not map 
> items, but map transitions. Suppose an imaginary initial state x. Now when we 
> call rand_1_5(), we have one of the following transition,
> 1) x -> 1
> 2) x -> 2
> 3) x -> 3
> 4) x -> 4
> 5) x -> 5
> Now, lets call rand_1_5() again, and remember the last transition, viz.
> 1) x -> 1 -> 1
> 2) x -> 1 -> 2
> 
> 24) x -> 5 -> 4
> 25) x -> 5 -> 5
>
> So we have 25 transitions. Divide it by 7, we get 4 as remainder and 3 as 
> quotient i.e. if we each number 1 to 7, three of these 25 transitions each, 
> we get 4 unused transitions. Lets take it to next level. We get 25*5 = 125 
> transitions. Divide by 7, we get 6 unused transitions. Still another level, 
> get us 125*5 = 625 transition, divide by 7, we get 2 as remainder. So nearest 
> we get is, 625*5*5 = 15624. Dividing by 7, we get 1 as remainder. So in 15625 
> transitions, (by calling rand_1_5() 6-times), we can assign 2232 
> unique-transitions to each on of 1,2,..,7. With just 1 un-assigned 
> transition, we get 1/15625 part-error, or 0.0064% error.
>
> Comments?
>
> On Sep 7, 10:56 am, ankur aggarwal  wrote:
>
> >   Given a random number generator that generates numbers in the range 1 to
> > 5, how can u create a random number generator to generate numbers in the
> > range 1 to 7. (remember that the generated random numbers should follow a
> > uniform distribution in the corresponding range)
>
>       Love Cricket? Check out live scores, photos, video highlights and more. 
> Click herehttp://cricket.yahoo.com


  Looking for local information? Find it on Yahoo! Local 
http://in.local.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: n balls having k colors

2009-09-08 Thread manish bhatia






From: ankur aggarwal 
To: algogeeks@googlegroups.com
Sent: Tuesday, 8 September, 2009 9:02:45 PM
Subject: [algogeeks] Re: n balls having k colors

int num_balls[K] = {0}; // one entry per color.
Use num_balls[] to count balls for each color. Now we just need to permute 
num_balls[].

"sort balls[] on the basis of code[color_tag]"

wat r u doing here ??

Well for what its worth, here I am sorting balls[] array such that instead of 
comparing balls[i] < balls[j], I am comparing, code[color(balls[i])] < 
code[color(balls[j])].

On Tue, Sep 8, 2009 at 8:35 PM, manish bhatia  wrote:

Assign 0 to K numbers to all K colors, such that color -> color_tag (a number 
b/w [0,K-1]).
>code[k] = {0,2,..,k-1}
>foreach (permutation from all possible-permuations of code[])
>    sort balls[] on the basis of code[color_tag]
>    print balls[]
>
>
>

From: ankur aggarwal 
>To: lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
>Sent: Sunday, 6 September, 2009 1:36:01 PM
>Subject: [algogeeks] n balls having k colors
>
>
>You have N balls having one of K colors. Arrange them into groups of same 
>colors. e.g.
>
>RRGRG
>can be arranged as
>RRRGG (Answer)
>GGRRR
>
>

See the Web's breaking stories, chosen by people like you. Check out Yahoo! 
Buzz.
>
>
>




@manish 
wat is the complexity ??
think about it... 

Yeah complexity is way off! Perhaps we can do the following (provided we can 
use extra space).


  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: linked list questions

2009-09-08 Thread manish bhatia
Are we able to store the incoming characters?

On Tue, Sep 8, 2009 at 11:51 AM, Bharath  wrote:


>Slightly modifying first question.
>
>Check whether a string is palindrome in single pass.
>
>Meaning an online algorithm is required, i.e. it must be able to read
>one character at a time from a stream and tells whether string read so
>far is palindrome or not.
>
>
>
>



  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: random number...

2009-09-08 Thread manish bhatia
I can think of 2 appraches.

[1] Similar to something already suggested. Just adding my 2 cents.

1 to 7 digits can be represented by 3 bits. So going by that,

int rand_1_7() {
 b1 = rand_1_5()*(7/5) > (7/2) ? 1 : 0;
 b2 = rand_1_5()*(7/5) > (7/2) ? 1 : 0;
 b3 = rand_1_5()*(7/5) > (7/2) > 1 : 0;
 return (b1*4 + b2*2 + b3*1);
}

[2] What we are trying to do is map numbers 1 to 5 to numbers 1 to 7. Of course 
mapping 5 items to 7 items is not straight forward. So lets not map items, but 
map transitions. Suppose an imaginary initial state x. Now when we call 
rand_1_5(), we have one of the following transition,
1) x -> 1
2) x -> 2
3) x -> 3
4) x -> 4
5) x -> 5
Now, lets call rand_1_5() again, and remember the last transition, viz.
1) x -> 1 -> 1
2) x -> 1 -> 2

24) x -> 5 -> 4
25) x -> 5 -> 5

So we have 25 transitions. Divide it by 7, we get 4 as remainder and 3 as 
quotient i.e. if we each number 1 to 7, three of these 25 transitions each, we 
get 4 unused transitions. Lets take it to next level. We get 25*5 = 125 
transitions. Divide by 7, we get 6 unused transitions. Still another level, get 
us 125*5 = 625 transition, divide by 7, we get 2 as remainder. So nearest we 
get is, 625*5*5 = 15624. Dividing by 7, we get 1 as remainder. So in 15625 
transitions, (by calling rand_1_5() 6-times), we can assign 2232 
unique-transitions to each on of 1,2,..,7. With just 1 un-assigned transition, 
we get 1/15625 part-error, or 0.0064% error.

Comments?



On Sep 7, 10:56 am, ankur aggarwal  wrote:
>   Given a random number generator that generates numbers in the range 1 to
> 5, how can u create a random number generator to generate numbers in the
> range 1 to 7. (remember that the generated random numbers should follow a
> uniform distribution in the corresponding range)


  Love Cricket? Check out live scores, photos, video highlights and more. 
Click here http://cricket.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: find triangle in a graph

2009-09-08 Thread manish bhatia
how about finding all the connected-components and checking which all have 3 
edges?





From: ankur aggarwal 
To: "i...@mca_2007" ; 
lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
Sent: Sunday, 6 September, 2009 2:58:40 PM
Subject: [algogeeks] find triangle in a graph


google question : find triangle in a graph
Given an undirected graph, design a O(V+E) algo to detect whether there is a 
triangle in the graph ot not. 


  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: n balls having k colors

2009-09-08 Thread manish bhatia
Assign 0 to K numbers to all K colors, such that color -> color_tag (a number 
b/w [0,K-1]).
code[k] = {0,2,..,k-1}
foreach (permutation from all possible-permuations of code[])
    sort balls[] on the basis of code[color_tag]
    print balls[]




From: ankur aggarwal 
To: lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
Sent: Sunday, 6 September, 2009 1:36:01 PM
Subject: [algogeeks] n balls having k colors

You have N balls having one of K colors. Arrange them into groups of same 
colors. e.g.

RRGRG
can be arranged as
RRRGG (Answer)
GGRRR


  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: Find longest palindrom in a give n string in O(N)

2009-09-06 Thread manish bhatia
Could you please elaborate?





From: ankur aggarwal 
To: algogeeks@googlegroups.com
Sent: Tuesday, 1 September, 2009 6:01:51 PM
Subject: [algogeeks] Re: Find longest palindrom in a give n string in O(N)




On Tue, Sep 1, 2009 at 2:24 PM, Nayn  wrote:


>"Working with stack doesn't work. Push down Automata is usefull in
>checking if a given string in palindrom or not... But useless for
>finding longest palindrom."

correct dufus 


>



  Love Cricket? Check out live scores, photos, video highlights and more. 
Click here http://cricket.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: path from n1 to n2

2009-08-28 Thread manish bhatia
How should a toposort help?





From: ankur aggarwal 
To: algogeeks@googlegroups.com
Sent: Thursday, 27 August, 2009 9:15:47 AM
Subject: [algogeeks] Re: path from n1 to n2


@
>_dufus
>
>
>i also think dfs can solve this problem widout topological sort
>
>



  Fitness on your mind? Check out nearby gyms on Yahoo! India Local 
http://in.local.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: path from n1 to n2

2009-08-28 Thread manish bhatia
A simple DFS should give you this (populating the path as we do the traversal). 
Now only question is when we get a forward-edge, i.e. a convergence-point, we 
have two options,

(Assuming that while coming back after hitting n2, we keep marking vertices 
which have n2 in the fanout, similarly mark nodes which do not have n2 in the 
fanout). Suppose we hit vertex v which is already visited and it has n2 in the 
fanout, (if n2 is not in the fanout, nothing to do, go back)

1. Allow traversal via this node and let it hit n2 again. This is 
memory-efficient but would take more run-time.
2. When you are coming back after hitting n2, at any vertex where there are 
more than one in-arcs, i.e. a potential convergence point, keep the path 
v-onwards, which will lead to n2. Now this will get complex in case of 
re-convergence, because then there will be more than one paths from v to n2.





From: ankur aggarwal 
To: "i...@mca_2007" ; 
lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com
Sent: Wednesday, 26 August, 2009 2:03:01 PM
Subject: [algogeeks] path from n1 to n2

given a directed graph and node n1 and n2 
find all possible path between them 

i think graph is acyclic ..
otherwise there are infinte path we can write 

eg

for  node "a" and "d" are there
we have a cycle  node "b"  to "c" and "c" to "b"  

a-> b->c->b->d
a-> b->c->b->c->b->d
etc



  Yahoo! recommends that you upgrade to the new and safer Internet Explorer 
8. http://downloads.yahoo.com/in/internetexplorer/
--~--~-~--~~~---~--~~
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: Merging companies

2009-08-25 Thread manish bhatia
Suppose nCp represents n!(n-p)!/p!

The product of the following should be the answer,

nC2 x (n-1)C2 x (n-2) x ... x 2C2

The above assumes that merger of company K1 with K2, gives rise to a new 
company K12, and merger of K12 with K3, and K13 with K2 is different.

How does it sound?

 


From: ankur aggarwal 
To: algogeeks@googlegroups.com; "i...@mca_2007" 
; lets-talk-g...@googlegroups.com
Sent: Tuesday, 25 August, 2009 12:28:48 AM,
Subject: [algogeeks] Merging companies

Merging companies
Suppose we have N companies, and we want to eventually merge them into
one big company. How many ways are there to merge?


  Love Cricket? Check out live scores, photos, video highlights and more. 
Click here http://cricket.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Re: Question asked in MS interview

2009-08-17 Thread manish bhatia
list lastNWords contains last N words, first being the one encountered 
most recently

// suppose following function gets called whenever a new word is encountered
void addNewWord(string newWord, map::iterator>& mp, 
list& lastNWords)
{
    lastNWords.push_front(newWord);
 if(mp.find(newWord) != mp.end()) {
 // newWord is already there
 lastNWords.erase(mp[newWord]);
 mp[newWord] = list.begin();
 } else {
    lastNWords.erase(lastNWords.rbegin());
 }
}





From: richa gupta 
To: algogeeks@googlegroups.com
Sent: Friday, 14 August, 2009 12:53:46 PM
Subject: [algogeeks] Question asked in MS interview


You have to develop a piece of code that can be attached to a program
like Microsoft Word, which would list the last "N" words of the
document in descending order of their occurence, and update the list
as the user types. What code would you write? Using pseudo code is
fine, just list the basic things you would consider

-- 
Richa Gupta
(IT-BHU,India)



  Yahoo! recommends that you upgrade to the new and safer Internet Explorer 
8. http://downloads.yahoo.com/in/internetexplorer/
--~--~-~--~~~---~--~~
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-17 Thread manish bhatia
Keep adding the digits till you are reduced to single digit. Then check if it 
is 3, 6 or 9





From: richa gupta 
To: programming-puzzles ; algogeeks 

Sent: Friday, 14 August, 2009 1:15:13 PM
Subject: [algogeeks] Check divisibility by 3


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)



  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



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

2009-08-11 Thread manish bhatia
Well instead of using extra memory, we can in-place sort the arraay  in 
O(nlog(n)) and then do an iteration (O(n)) to find out the repeated number. But 
the catch is that number is repeated 2^i times. That is the hint we should use





From: ankur aggarwal 
To: algogeeks@googlegroups.com
Sent: Sunday, 9 August, 2009 5:47:32 PM
Subject: [algogeeks] Re: Finding repeated element in most efficient way


@richa.. 
ques is in complete i think .
there shud be some conditions given .. 

otherwise 
hash them 
but lots of space will b wasted.. 


or sort them 

try to put the conditions.. 
 




  Yahoo! recommends that you upgrade to the new and safer Internet Explorer 
8. http://downloads.yahoo.com/in/internetexplorer/
--~--~-~--~~~---~--~~
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: Spell Checker

2009-07-31 Thread manish bhatia
He meant alternate-spellings! Just like you get from MS-Word et. al.





From: Vikram Sridar 
To: algogeeks@googlegroups.com
Sent: Friday, 31 July, 2009 7:03:54 PM
Subject: [algogeeks] Re: Spell Checker

Alternatives?? what way??

In terms of implementation or providing some other functionalities??



  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.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
-~--~~~~--~~--~--~---



[algogeeks] Allocation problem

2009-06-18 Thread Manish Garg
Hi,

This is an allocation problem, where rules for allocation is given in ratio.
These ratios are maintained in a 2-d matrix. While creating the ratios we do
not have any restriction. So there is possibility of circular allocation,
but infinite loop won't be there. Following is the example:

A is allocating to B, C, D in ratio 0.2, 0.4 and 0.4

A --> B 0.2
C 0.4
D 0.4

D is again allocating to E and A in ratio 0.6 and 0.4:

D --> E 0.6
A 0.4

These allocation will end when allocation to X, Y and Z happen.

C, D and E is allocating to X, Y and Z respectively in ratio 1.

Now we need to find out an allocation of $100 starting from A. in what ratio
other will get. Basic need to resolve the loop A --> D --> A.

[It is given that there will not be infinite loop. Means A -- > B 1 --> A 1
won't be there.]

There won't be any allocation if its less then 0.1.

Right now I am using:

1. Starting allocation from A. Divide among all sub parts. Add each
separately in a queue.

2. Get first item from queue. If its allocated to X, Y, or Z then insert
into separate storage queue. Else If value greater then 0.1 then
divide and insert into queue.

3. Repeat steps one and two till queue is empty.

Please suggest the solution that can fit in loop of any level down.

-- 
With Best Regards...
---
Manish

--~--~-~--~~~---~--~~
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: Array of integers

2007-11-19 Thread Manish Garg

can find in O(n) if array is sorted

On Nov 18, 2007 9:13 AM, dor <[EMAIL PROTECTED]> wrote:
>
> You can do it in O(n log(n)) (without extra space). If you can afford
> O(T) extra space (where T is the largest number in the array, in
> absolute value), you can do it in O(n).
>
>
> On Nov 17, 3:42 pm, geekko <[EMAIL PROTECTED]> wrote:
> > Suppose that you have an array of integers. Given a number X are there
> > any two numbers in the array in which their summation is equal to the
> > X? Can you find a solution in O(n)?
> >
>



-- 
With Best Regards...
---
Manish

--~--~-~--~~~---~--~~
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: selecting data region, 2d, multi-d

2007-08-11 Thread Manish Garg
>
>
> Selecting a rectangle is O(log N * M) where M is the number of
> datapoints in the 'band'.
> Anyone know of anything better?
>


i think u can come up with an proof that we can make any algorithm that has
complexity less then O(log N * M)...if u have all point array sorted...
one more thing...that before searching the point u actually sorting the
points...that is taking complexity O((N*logN)*M) at laest..
so order of complexity is O(N*lonN) if M

[algogeeks] Re: Longest Common Sequence

2007-08-11 Thread Manish Garg
actually problem is not clear...

is this ur problem thatur regular expression contains the list of 300
zip codes
and u want to search that on any string...that if any zip code is present it
will report...and u want us to give suggestion to make this regular
expression shorter

is this the problem??

On 8/7/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> I have a regexp which looks like:
>
> ^94530|94540|a very long list of zip codes separated by ||
> 94397$
>
> I want to reduce the regexp length. How can I do that? TIA.
>
> On Jul 31, 5:58 pm, dor <[EMAIL PROTECTED]> wrote:
> > On Jul 23, 10:29 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> >
> > > I have a list of zip codes (300) and I want to compress it so that my
> > > regexp is concise. Can someone give me some pointers please? TIA.
> >
> > What regular expression might that be? What's the connection between
> > the title of your post and the problem you are trying to solve?
> > Can you be a little more precise?
>
>
> >
>


-- 
With Best Regards...

Manish

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



  1   2   >