Re: [algogeeks] Re: MS Interview

2011-06-11 Thread Ashim Kapoor
Could someone illustrate the XOR for question 2. I am a beginner to this. Many thanks! On Thu, Jun 9, 2011 at 4:58 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: Xoring it twice ...once with the elements in the file and then from i=1 to 4,000,000,000..the answer left is the missing number

Re: [algogeeks] MS Q

2011-06-11 Thread Ashim Kapoor
I think RGGB is invalid as we have 4 different colors. On Fri, Jun 10, 2011 at 10:10 AM, Harshal hc4...@gmail.com wrote: #includeiostream #includestring using namespace std; void mastermind(char* guess, char* sol, int *hits, int *pseudohits) { int temp[256] = {0}; int

Re: [algogeeks] GOOGLE Q

2011-05-20 Thread Ashim Kapoor
How will BFS give a rearrangement ? -- 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

Re: [algogeeks] Application of Data Structure System Design

2011-04-06 Thread Ashim Kapoor
int max_calls[no_of_customers][30]; On any phone call -- max_calls[customer_id][day]++; On hangup -- max_call[customer_id][day]--; This would store max calls for each customer on each day. Does the length of the call have to be taken into account ? Your question is not clear on that. On Tue,

Re: [algogeeks] Application of Data Structure System Design

2011-04-06 Thread Ashim Kapoor
]--; On Tue, Mar 29, 2011 at 4:29 PM, Ashim Kapoor ashimkap...@gmail.com wrote: int max_calls[no_of_customers][30]; On any phone call -- max_calls[customer_id][day]++; On hangup -- max_call[customer_id][day]--; This would store max calls for each customer on each day. Does the length of the call

Re: [algogeeks] finds a pair of close numbers

2011-04-06 Thread Ashim Kapoor
On Fri, Apr 1, 2011 at 6:02 PM, snehal jain learner@gmail.com wrote: For a set S of n real numbers, a pair of elements x, y belong to S, where x y, are said to be close if y – x = ( max(S) – min(S) ) / (n-1) Suppose you are given an unsorted array A[1 : n] of distinct real numbers.

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread Ashim Kapoor
One more query, insert into bst is O(n) and then do inorder to get them in sorted order. This is an example of sorting in O(n) time. is this correct? On Mon, Mar 28, 2011 at 6:06 PM, Ashim Kapoor ashimkap...@gmail.com wrote: How do you use inorder traversal to find longest sub sequence

Re: [algogeeks] Re: Check out One More Interesting Challenging Question...Longest Consecutive Elements Sequence.

2011-04-06 Thread Ashim Kapoor
How do you use inorder traversal to find longest sub sequence? On Mon, Mar 28, 2011 at 6:03 PM, bittu shashank7andr...@gmail.com wrote: its (not aplicable). sorting nlogn i said time O(n) O(1) space i think we can use BST , put all elements in BST O(n) then do inorder to find longest

Re: [algogeeks] Re: finds a pair of close numbers

2011-04-06 Thread Ashim Kapoor
Hi , Use Hashing for That , for sum =12 arr[]={2,4,3,6,5,8,7}; store in to hashtable for each index=0 in loop find sum-arr[index] so fro sum =12 if we do index=1 a[1]=4 sum-a[1]=8 so stop it we have done..hope make d perfect code. time Complxity o(n) space size of hashtable Let me

Re: [algogeeks] Re: Application of Prime Number . An Interesting For Geeks

2011-03-26 Thread Ashim Kapoor
Dear Shashank, What you are trying to do is called Goldbach's conjecture . Google for it. There is a million dollar prize to prove it. Ashim On Thu, Mar 24, 2011 at 8:03 PM, ligerdave david.c...@gmail.com wrote: I have to say: to prove the correctness of this hypotheses is a wrong question

Re: [algogeeks] Pairwise Sum Array

2011-02-26 Thread Ashim Kapoor
I think the output is wrong. It should be 1 3 4 9 n in no call them ai's a[1] to a[n] 4 5 10 7 12 13 m in no call them bi's b[1] to b[m] I assume starting from 1 to make manipulation easier n(n-1)/2= m n(n-1)=2m n2 -n -2m=0 using quadratic formula:- n=1 + sqrt( 1+8m)/2 This will always be a

Re: [algogeeks] Pairwise Sum Array

2011-02-26 Thread Ashim Kapoor
That is exactly what my solution is doing. On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: There must be another good solution..please let me know . Thanks On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal ashish.cooldude...@gmail.com wrote: I think..

Re: [algogeeks] Application Data Structure In Collision Detection

2011-02-22 Thread Ashim Kapoor
also since each object is a rigid body each point in any one object will have the same equation of motion. On Wed, Feb 16, 2011 at 8:04 PM, Ashim Kapoor ashimkap...@gmail.com wrote: Here is my attempt it's very naive but maybe someone can improve each object be a pointer to a set of points

Re: [algogeeks] Application Data Structure In Collision Detection

2011-02-22 Thread Ashim Kapoor
Here is my attempt it's very naive but maybe someone can improve each object be a pointer to a set of points { these points are the boundary of the object } Collision detection : Sweep through each pair of pointers to check for equality of the boundary points. an example , there are 3 objects

Re: [algogeeks] program for evaluation of remainders

2010-12-08 Thread Ashim Kapoor
Let me try. Any thing involving n would leave no remainder. so (1 + 2 ! + ... + n ! + + N !) mod n = (1 + 2 ! + ... + (n-1)! ) mod n This should be computed from a loop. I don't know how to reduce it further. Ashim. On Wed, Dec 8, 2010 at 6:49 PM, ankit sablok ankit4...@gmail.com wrote:

Re: [algogeeks] Amazon Interview Question

2010-12-05 Thread Ashim Kapoor
What if we have an array :- index - 1 2 3 4 5 value - 1 2 3 4 5 How will ANY logn solution determine all ALL elements are equal to it's index value ? Maybe I misunderstand. Thank you, Ashim On Sat, Dec 4, 2010 at 5:38 PM, ankit sablok ankit4...@gmail.com wrote: u can then move to other

Re: [algogeeks] Re: Amazon Interview Question

2010-12-05 Thread Ashim Kapoor
yaar I can use simple O(n) sweep to find out who all are equal, I think it can't be less than this On Sat, Dec 4, 2010 at 8:05 PM, Abioy Sun abioy@gmail.com wrote: 2010/12/4 ankit sablok ankit4...@gmail.com: as all the elements are sorted in the array make a min heap of the array

Re: [algogeeks] Mathematics Puzzle

2010-11-21 Thread Ashim Kapoor
Do you mean if the rank of a student is better than the rank of the prev student then he/she gets a lollipop? Thank you, Ashim On Sun, Nov 21, 2010 at 6:57 PM, vamsee marpu marpu.vam...@gmail.comwrote: Does anybody know the solution for the following problem : *A headmaster of a primary

Re: [algogeeks] student introduction problems

2010-11-07 Thread Ashim Kapoor
Is'nt this solvable by the majority vote algorithm already discussed in this list? Ashim. On Sun, Nov 7, 2010 at 3:42 AM, lichenga2404 lichenga2...@gmail.com wrote: There are many secret groups in College A.Every student at college A is a member or these secret group, though membership in one

Re: [algogeeks] Yahoo coding round question

2010-10-21 Thread Ashim Kapoor
I'm not sure what a 2 hash table is. Can you please explain ? On Tue, Oct 19, 2010 at 10:36 PM, MOHIT mohit...@gmail.com wrote: o(n) soln Lets say A is the array of length N. Create an array sum of length N and initialize it to 0. Create an array product of length N and initialize it

Re: [algogeeks] Re: Drawing a graph

2010-09-17 Thread Ashim Kapoor
what is this red book ?full name please? On Fri, Sep 17, 2010 at 1:01 PM, vikas kumar vikas.kumar...@gmail.comwrote: use opengl library to draw the graph or whatever. take RED BOOK for reference. On Sep 14, 5:54 pm, Mithun avmit...@gmail.com wrote: Can anyone help me with the code for

Re: [algogeeks] Re: Amazon Question

2010-09-13 Thread Ashim Kapoor
How would you define 50% or more similarity ? On Sun, Sep 12, 2010 at 6:49 PM, Chi c...@linuxdna.com wrote: trie On Sep 12, 3:09 pm, sharad kumar aryansmit3...@gmail.com wrote: pagerank algo On Sun, Sep 12, 2010 at 5:42 PM, Snoopy Me thesnoop...@gmail.com wrote: You are given

Re: [algogeeks] Aricent question

2010-09-11 Thread Ashim Kapoor
The majority vote program ( discussed a couple of days ago ) would work in this case I think. In the end we would have the modal element with count = 0 (n - n ). Please correct me if I am wrong. On Sat, Sep 11, 2010 at 3:00 PM, bittu shashank7andr...@gmail.com wrote: Given an array of 2n

Re: [algogeeks] cyclic String

2010-09-11 Thread Ashim Kapoor
I can do it in 2 O(n)sweeps if all elements are distinct. 12345 23451 Sweep one to find the 1st element of string 1 in string 2. Sweep 2 to compare each element of the 2 strings from the position mod n found in the 1st sweep. I dont know how to do it if elements are repeated. but the way

Re: [algogeeks] DeShaw Question....tough One

2010-09-06 Thread Ashim Kapoor
int a[]={11,9,8,2,10,7,3,4,5} max_length = 1 ; current_length = 1; first_position=0 ; last_position = 0 ; first_position_max=0; // Sweep one to find the length of the longest subsequence. for ( i = 1 ; i n ; i++ ) { if ( a[i] a[i-1] ) { last_position=i-1;

Re: [algogeeks] kth smallest element in a heap x

2010-08-21 Thread Ashim Kapoor
sure, but the implementation is confusing. My question is does not the 2nd count overwrite the 1st value of count in side the function? Thank you. On Sun, Aug 22, 2010 at 1:04 AM, Harshal ..Bet oN iT!! hc4...@gmail.comwrote: if it is a min heap,, then traversing down from the root node, it

[algogeeks] kth smallest element in a heap x

2010-08-20 Thread Ashim Kapoor
Dear All, I found this in the book by skeina. Problem: Given an array-based heap on n elements and a real number x, efficiently determine whether the kth smallest element in the heap is greater than or equal to x. Your algorithm should be O(k) in the worst-case, independent of the size of the

Re: [algogeeks] minimum window containing charecters

2010-08-01 Thread Ashim Kapoor
I am not sure, but can I do this using a suffix trie ? any comments ? On Sun, Aug 1, 2010 at 2:29 PM, Ashish Goel ashg...@gmail.com wrote: solution could be to find the charcter position from both sides for each char of s2 then from the 2*n array, find the smallest index from left and

Re: [algogeeks] Finding the mode in a set of integers

2010-04-17 Thread Ashim Kapoor
are you referring to the lectures by Dr Naveen Garg ? Or are these lectures different? Please clarify. Thank you, Ashim. On Sat, Apr 17, 2010 at 5:43 AM, rahul rai raikra...@gmail.com wrote: On 4/16/10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Just got another O(n) solution. Find

Re: [algogeeks]

2010-03-31 Thread Ashim Kapoor
I think it can be done in logn time ( I assume the list is sorted, is there an order log n sorting algo, then i can even sort it in log n time ? ( I am new to algorithms ) ). 1. binary search for low=x1. 2. binary search for high=x2. both will take log n time. Print all values between them then