Re: [algogeeks] MS Design Ques

2012-07-06 Thread Mithun Kumar
@anshuman...

Are you converting numbers to string because data types ranges
and precision differs? or is there any other reason?

-mithun

On Fri, Jul 6, 2012 at 12:58 AM, payal gupta gpt.pa...@gmail.com wrote:

 thnx...4 d rply..

 Regards,
 PAYAL GUPTA,
 NIT-B.


 On Fri, Jul 6, 2012 at 12:43 AM, Anshu Mishra 
 anshumishra6...@gmail.comwrote:

 First define all the basic operation you can apply on two numbers.

 Binary operation : +, -, *, /, %, optional((and), |(or), ^(xor))
 Unary operation : !, ~, -
 Comparison : ,  ==, !=

 Define all these operation.

 Most simplest one can be,
 class BIG_INT {
private string val;
//Define constructor
private BIG_INT(){}
public BIG_INT(int x) {
this.val = x.toString();
}
public BIG_INT(long x) {
this.val = x.toString();
}
public BIG_INT(string x) {
this.val = x;
}
public BIG_INT add(BIG_INT x);
public BIG_INT add(int x);
public BIG_INT add(long x);

   similarly write methods for other operation also;

   }

 If this question asked for only design testing purpose only all method
 declaration will be sufficient.

 --
 Anshuman Mishra | Software Development Engineer | Amazon


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


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


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



Re: [algogeeks] MS Design Ques

2012-07-03 Thread Mithun Kumar
can you elaborate question...what is BIG_INT?



On Sun, Jul 1, 2012 at 8:13 PM, payal gupta gpt.pa...@gmail.com wrote:

 design a BIG_INT library...

 Regards,
 PAYAL GUPTA,
 NIT-B.

 --
 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/-/EHIiPPFJ4t0J.
 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] MS Question :implement read write lock class

2012-06-29 Thread Mithun Kumar
This link should help

http://stackoverflow.com/questions/5667793/how-does-a-read-write-mutex-lock-work?rq=1

-mithun



On Fri, Jun 29, 2012 at 7:30 AM, bharat b bagana.bharatku...@gmail.comwrote:

 class lock
 {
  enum{read, write,free}status;
 };
 By default, make status value as free.
 Based on the request, status value will be changed...
 Based on the value of the status, we should decide whether another
 read/write lock can be given.

 Any suggestions ?
 On Thu, Jun 28, 2012 at 4:46 PM, Ashish Goel ashg...@gmail.com wrote:


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

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


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


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



Re: [algogeeks] Re: Amazon Question

2012-05-21 Thread Mithun Kumar
Shouldn't having 2 queues one storing the node and other corresponding
level should be sufficient and do level order traversal?

-mithun




On Mon, May 21, 2012 at 5:54 PM, Ashish Goel ashg...@gmail.com wrote:

 bool firstCousins(struct node * pRoot, struct node *pThis, (struct
 node*)[] path, int pos, vectorint firstCousins)
 {
 if ((!pThis) || (!pRoot)) return false;
 if (pRoot-data!=pThis-data) {
   path[pos] = pRoot;
   if (!findCousins(pRoot-left, pThis, path, pos+1, firstCousins))
 return findCousins(pRoot-left, pThis, path, pos+1, firstCousins);
 }
 if (pos2) return false; //this node is at level 0 or level 1
 struct node* pGP = path[pos-2];
 struct node *pParent = path[pos-1];
 struct node *pUncle = NULL;
 if (pParent == pGP-left)
 {
   pUncle = pGP-right;
 }else pUncle = pGP-left;
 if (pUncle-left) firstCousins.add(pUncle-left-data);
 if (pUncle-right) firstCousins.add(pUncle-right-data);
 return true;
 }


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


 On Mon, May 21, 2012 at 5:41 PM, Ashish Goel ashg...@gmail.com wrote:

 For this the cousins of 1 should be  9   8 12  13   14   15  how
 then can it be a 2 pass algorithm... we should also consider great
 grandparent as in this case ... Correct me if I m wrong!!

 the first cousins are  9,8 not 12,13...otherwise the question becomes
 really simple :)

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


 On Mon, May 21, 2012 at 12:54 PM, sivaviknesh sivavikne...@gmail.comwrote:

 For this the cousins of 1 should be  9   8 12  13   14   15  how
 then can it be a 2 pass algorithm... we should also consider great
 grandparent as in this case ... Correct me if I m 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.



Re: [algogeeks] Sorting in O(n)

2012-05-21 Thread Mithun Kumar
using bit array we can sort elements in O(1)

-mithun



On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.comwrote:

 How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas?

 --
 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/-/PGgMdaIbGIsJ.
 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 interview question

2012-05-21 Thread Mithun Kumar
By doing Ex-OR we can find if b is permutation of A

suppose a --  3 5 4
 b --  4 3 5
if A ^ B = 0 then both are permutation or else not

shout loud if this has flaws :P

-mithun



On Sun, May 20, 2012 at 12:59 AM, HARSHIT PAHUJA hpahuja.mn...@gmail.comwrote:

 given 2 unsorted integer arrays a and b of equal size. Determine if b is a
 permutation of a. Can this be done in O(n) time and O(1) space ?




 please help me with my solution


 suppose a --  3 5 4
  b --  4 3 5

 now we replace a[i] with a[i]..th prime number  and b with b[i] .. th
 prime number

   now array  a becomes  5 11 7
  array  b becomes  7 5 11

 now we take product of elements of array a and do the same with array  b
 elements
 if product is equal  then b is a permutation of a

 --
 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: Good problem

2009-10-20 Thread Mithun Kumar Singh
Hi,
   This problem is same as a Travelling salesman problemIn
travelling salesman we need to cover points in Min distance...here we need
to just opposite..

PS: Answer may be misleading ...if so Pls correct me... :)

-Mithun




On Tue, Oct 20, 2009 at 6:16 PM, monty 1987 1986mo...@gmail.com wrote:

 Hi,
   Still waiting for solution...

 On Wed, Oct 7, 2009 at 3:18 PM, monty 1987 1986mo...@gmail.com wrote:

 The important thing is all the points do not lie in same range i.e.
 x1 ,x2 ,x3 each of them have their own range.


 On Wed, Oct 7, 2009 at 3:15 PM, monty 1987 1986mo...@gmail.com wrote:

 The min. distance between two points i.e. the euclidean distance between
 two points.


 On Tue, Oct 6, 2009 at 5:52 PM, MrM maleki...@gmail.com wrote:


 you can arrange them with equal distances !
 if n=1 then, it does not matter where you put the point !
 if n1 then, put them with distances = (r2i-r1i) / (n-1) !
 it means ou put the first point on r1i and the last point on r2i, the
 remaining point are distributed with equal distances !

 On Oct 5, 5:22 pm, monty 1987 1986mo...@gmail.com wrote:
  We have to locate n points  on the x-axis
  For each point xi
  the x co-ordinate of it lies between a
 range
  [r1i,r2i]
  Now we have to decide the location of points such that
  minimum { distance between any two points } is maximum.
 
  Any answer is welcomed.






 


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