Re: [algogeeks] ThreeListSum

2011-01-10 Thread juver++
There is no need to sort first two arrays. -- 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.

Re: [algogeeks] Re: Adobe Interview Question

2011-01-10 Thread Arpit Sood
@jammy your code isnt working for the mentioned test case. One simple approach is to go greedy on the test data, but that wont always give the optimum answer. On Tue, Jan 11, 2011 at 1:11 PM, Arpit Sood wrote: > the output for first test case is wrong it should be > (John)1 4 5 6 2 2 - (Mary

[algogeeks] Re: Tejas Networks - Written Test

2011-01-10 Thread juver++
1. Any shortest path algorithms on graphs (Dijkstra, Bellman-Ford, Floyd). 2. Store it's edges while doing DFS. -- 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 fr

Re: [algogeeks] Re: Adobe Interview Question

2011-01-10 Thread Arpit Sood
the output for first test case is wrong it should be (John)1 4 5 6 2 2 - (Mary)2 2 4 5 6 1 1 7 8 -- (Mary) 8 1 7 minimum cuts made are 2 On Tue, Jan 11, 2011 at 10:04 AM, Jammy wrote: > (a) it is intuitive to see we need to make a recursive function which > takes the following argument

Re: [algogeeks] ThreeListSum

2011-01-10 Thread Puneet Ginoria
sort all 3 arrays. then for any every combination of numbers in 2 arrays say, a and b do a binary search for element -(a+b) in the third array. It would be a O(N^2 logN) algorithm On Tue, Jan 11, 2011 at 12:04 PM, Decipher wrote: > Given three lists: A, B and C of length n each. Write a function

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-10 Thread juver++
About 2 stack implementation. Yes some operations can be O(n) as a separate estimation. But all other will be constant, cause we access elements at most twice. So for the sequence of M operations (pop,push,min) total complexity will be O(M), so the average cost of each operations is O(1). There a

[algogeeks] Tejas Networks - Written Test

2011-01-10 Thread Decipher
This was asked by Tejas Networks during campus recruitment in written test . 1) Given a matrix m[i][j] = distance traveled to go from i_th station to j_th station .WAC to find the minimum distance traveled to go from 0_th station to n_th station. 2) How will you store a tree in a file and then re

[algogeeks] ThreeListSum

2011-01-10 Thread Decipher
Given three lists: A, B and C of length n each. Write a function which returns true if any 3 three numbers (1 from each list), sum up to zero. Else return false, if there is no such combination. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou

[algogeeks] Re: Amazon Intrerview

2011-01-10 Thread Decipher
DFS and BFS won't work . Eg : check guptaz post and tell me how its gona work if x = A , y = D and z = C. The only solution is through LCA . -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@goog

[algogeeks] Re: Adobe Interview Question

2011-01-10 Thread Jammy
(a) it is intuitive to see we need to make a recursive function which takes the following arguments: 1) array, 2) start index, 3) length of the array, 4) a sentinel indicating if it is the first half or second half 5) a sum if it is the second half 6) number of cuts so far

Re: [algogeeks] Re: Adobe Question

2011-01-10 Thread vinayan c
make a running sum with -1 instead of 0 keep an array of the running sum.in the array find out the indexes with with equal sum at farthest distance...those two will be the bouding points of maximum subsesequence.. On Sun, Jan 9, 2011 at 10:19 PM, bittu wrote: > i think its DP Problemstil

Re: [algogeeks] Re: Amazon Intrerview

2011-01-10 Thread saurabh gupta
the question is: does B lie in the path from A to C below? D / \ / \ A M / \ /\ BC if yes, DFS suffices. if no, it doesn't. LCA method would work in this case. On Sun, Jan

[algogeeks] SPOJ : Problem 8055

2011-01-10 Thread mohit mittal
https://www.spoj.pl/problems/AMR10A/ Logic : Cannot find the area on the fly for all Q - Precompute the area of all polygons with a segment joining 0 and x as end points. - We can do this by using area of [0,x-1] and area of triangle [0,x-1,x] I have implemented this but i am not able to find my

Re: [algogeeks] Re: tic tac toe

2011-01-10 Thread Amir hossein Shahriari
i think we can do this if the last move is given and that we have processed the previous moves before, so only O(n) time is required if the last move's column row or diagonal is filled or not -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To

Re: [algogeeks] Re: Serialization in BT

2011-01-10 Thread Carl Barton
If it's in array representation the simplest way is just serialise the array? Linked i'd agree with snehal On 9 January 2011 11:54, juver++ wrote: > And this: > http://www.cs.usfca.edu/~galles/cs245/lecture/lecture9.pdf > > -- > You

Re: [algogeeks] Re: Adobe Interview Question

2011-01-10 Thread Anand
Heard of In place shuffle!!! http://arxiv.org/PS_cache/arxiv/pdf/0805/0805.1598v1.pdf On Mon, Jan 10, 2011 at 10:32 AM, shady wrote: > any one with basic approach for these kind of problems > > > On Mon, Jan 10, 2011 at 11:38 PM, shady wrote: > >> Given an array of numbers : a1, a2, a3.

Re: [algogeeks] Re: Histogram Problem

2011-01-10 Thread Anand
Engish version is available On Mon, Jan 10, 2011 at 11:22 AM, juver++ wrote: > Here is an algorithm for > the finding zero matrix with max area. > It is in Russian, however. > > -- > You received this message because you are subscribed to the Google

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-10 Thread SVIX
@ Juver, I got the following response in the group digest mail. It'll be great if you can provide some inputs so I can refine my understanding... Could you please help me understand how my delete operation takes O(n) time for every delete? I propose to maintain the minimum at the queue level (one

[algogeeks] Re: Histogram Problem

2011-01-10 Thread juver++
Here is an algorithm for the finding zero matrix with max area. It is in Russian, however. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googleg

[algogeeks] Re: Histogram Problem

2011-01-10 Thread Decipher
Does anyone know where is the solution to rectangle problem in this group ?? -- 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 algog

Re: [algogeeks] Re: Counting

2011-01-10 Thread sunny agrawal
3 <= N < 10^9 1 <= K <= 7 On Tue, Jan 11, 2011 at 12:40 AM, juver++ wrote: > What are the contaraints on 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 unsubs

[algogeeks] Re: Counting

2011-01-10 Thread juver++
What are the contaraints on 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 op

[algogeeks] Counting

2011-01-10 Thread Sunny
Number of Ways of arranging N 0's, N 1's and N 2's such that number of 0's are always greater than equal to number of 1's till any place but not more than by K and similarly number of 1's are always greater than equal to number of 2's till any place but not more than by K? -- You received this me

[algogeeks] Re: Adobe Interview Question

2011-01-10 Thread shady
any one with basic approach for these kind of problems On Mon, Jan 10, 2011 at 11:38 PM, shady wrote: > Given an array of numbers : a1, a2, a3. an > (a)divide them in such a way that every alternate segment is given to > two persons john and mary, equally the number of segmen

[algogeeks] Re: Adobe Question

2011-01-10 Thread Aviral Gupta
Replace 0 by -1 and make a[i] as sum of all a[j] j<=i Now u need to find the subarray with sum 0 For this u can use array of size 2n denoting -n to n Now at sum u can update array of 2n size with the index just found corresponding to that sum Overall complexity O(n) Regards http://coder

[algogeeks] Adobe Interview Question

2011-01-10 Thread shady
Given an array of numbers : a1, a2, a3. an (a)divide them in such a way that every alternate segment is given to two persons john and mary, equally the number of segments made should be minimum... eg for input 1 4 5 6 2 2 2 2 4 5 6 1 1 7 8 8 1 7 segments : (John)1 4 5 6 2 2

[algogeeks] Re: Adobe Question

2011-01-10 Thread Aviral Gupta
Replace 0 by -1 and make a[i] as sum of all a[j] j<=i Now u need to find the subarray with sum 0 For this u can use array of size 2n denoting -n to n Now at sum u can update array of 2n size with the index just found corresponding to that sum Overall complexity O(n) Regards http://coder

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern for all elements while shuffling. For all elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<= i <= N

Re: [algogeeks] Re: SUMMER INTERNSHIP

2011-01-10 Thread cr.a...@gmail.com
Dept of EE at IISc: http://www.ee.iisc.ernet.in/internship.html Dept. of CSA should have their's soon Anil On Mon, Jan 10, 2011 at 7:26 PM, Aviral Gupta wrote: > You can consider submitting ur resumes for the internships in various > IITs(forms for m

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern for all elements while shuffling. For all elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<= i <= N

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern all elements for following while shuffling. All elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<=

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern all elements for following while shuffling. All elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<=

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b1,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern all elements for following while shuffling. All elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<=

[algogeeks] Market Advisory Daily Tips for Free via SMS (www.sungodlaxmi.com)

2011-01-10 Thread raobhasha4
If you have trouble viewing or submitting this form, you can fill it out online: https://spreadsheets.google.com/viewform?formkey=dDRGaGRtei1PeDU2emIyUHRuSDhXVHc6MQ Market Advisory Daily Tips for Free via SMS (www.sungodlaxmi.com) I am Free Lance Market researcher involved in market research

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread anurag.singh
OK. I hope following should do the needful. Input: a1,a2,a3,a4,.aN,b1,b2,b3,b4,.,bN Output: a1,b2,a2,b2,a3,b3,a4,b4,..aN,bN. If we notice, there is a pattern all elements for following while shuffling. All elements from 1st half portion (a1 to aN) a[i] is moved to a[2*i] where 0<=

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-10 Thread juver++
You should analyze your algo more precisely and study something about amortized time complexity. Your delete operation takes O(n) time for EVERY query. So for the sequence of M deletetions there is an average time O(N) which is NOT constant on the worst case. -- You received this message becau

[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-10 Thread SVIX
yes... thats true... for the amortized constant time algo, u do a O(n) operation for one of the delete operations... my version does a O(n) operation for deletes of the min element... Min element can be deleted only when it's either in the front or at the back (using delete_front or the regular del

[algogeeks] Re: SUMMER INTERNSHIP

2011-01-10 Thread Aviral Gupta
You can consider submitting ur resumes for the internships in various IITs(forms for most of them are released in jan-mar) Regards http://coders-stop.blogspot.com/ On Jan 9, 6:47 pm, Decipher wrote: > Post your resume on some Job search website or try LinkedIn(Job search > option) . In the searc

Re: [algogeeks] Re: Linear Recurrences

2011-01-10 Thread juver++
What??? I've posted you the right way. -- 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

Re: [algogeeks] Re: Linear Recurrences

2011-01-10 Thread mittal
Thats my problem. that i am not use mod operator in between and i am not able to store that large value in a variable so that i can take it mod with 107 later. this for what i want a suggestion how to get mod in bw or is there some other way i can approach. Well this is for problem Fibos

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread juver++
There is only one single array. -- 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 o

[algogeeks] Re: Adobe - Algorithm

2011-01-10 Thread mittal
First of all you should have the maximum size of second array as sum of size of two arrays. let size of 1st=k and of 2nd = l then for (i=k+l;i>=1;i--) { b[i]=b[l]; b[i-1]=a[k]; k--;l--; } Add some special cases. -- You received this message because you are subscribed to the Google Groups "Al

Re: [algogeeks] Re: Linear Recurrences

2011-01-10 Thread juver++
When you does multiplication of the matrixs A*B, use mod. FOR (i, n) FOR (j, n) { result[i][j] = 0; FOR (k, n) result[i][j] = (result[i][j] + a[i][k] * b[k][j]) % MOD; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this gr

Re: [algogeeks] Re: Linear Recurrences

2011-01-10 Thread mittal
I want to calculate nth term of fibonacci when my n is large. n is probably 10^9. so my F(n) will be something which i cant store in long long or any other. i want to get F(n)mod10007. I am using this method of matrix exponentiation. My initial matrix is {1 0}

Re: [algogeeks] Re: Single linked list questions.

2011-01-10 Thread Harshal
@SVIX group members still can post the questions they consider good, doesnt matter they were able to solve it or not. There can be many ways to solve the same question. On Fri, Jan 7, 2011 at 12:39 AM, SVIX wrote: > are u sure u were not able to solve this on ur own? > > On Jan 6, 3:26 am, dinesh

[algogeeks] CFP: The 2011 International Conference on Foundations of Computer Science (FCS'11), USA, July 18-21, 2011

2011-01-10 Thread A. M. G. Solo
   CALL  FOR  PAPERS and   Call For Workshop/Session Proposals       FCS'11    The 2011 International Conference on Foundations of Computer Science      Date and Location: July 18-2