Re: [algogeeks] Re: MS Q

2012-07-11 Thread ANKIT BHARDWAJ
anybody have informaton regarding questions asked in written and interview of capillary technology for developer post please share at bhardwaj.ankit...@gmail.com thanks in advance. On 5/22/12, Navin.nitjsr navin.nit...@gmail.com wrote: If the matrix is 4-connected, we can use the same matrix.

[algogeeks] Re: MS Q

2012-05-23 Thread Navin.nitjsr
If the matrix is 4-connected, we can use the same matrix. now we have to find the total number of connected components of a graph. consider 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 we can use bfs/dfs to mark the nodes as visited and thus total

Re: [algogeeks] Re: MS Q

2012-01-24 Thread praveen raj
Idea: 1)Take count =0; 2) make Outer loop ...and search for 1's . 3) Start ...searching for 1 consecutively... and make it ..0 untill all consecutive 1's becomes 0.. and then count++ 4) go to 1) untill all 1's finished.. count will give the total number of islands... PRAVEEN RAJ

Re: [algogeeks] Re: MS Q

2012-01-24 Thread atul anand
@Praveen : i have doubt in your algo...it seem it may fail for some cases... On Tue, Jan 24, 2012 at 5:59 PM, praveen raj praveen0...@gmail.com wrote: Idea: 1)Take count =0; 2) make Outer loop ...and search for 1's . 3) Start ...searching for 1 consecutively... and make it ..0

Re: [algogeeks] Re: MS Q

2012-01-24 Thread praveen raj
name it. PRAVEEN RAJ DELHI COLLEGE OF ENGINEERING On Wed, Jan 25, 2012 at 12:45 AM, atul anand atul.87fri...@gmail.comwrote: @Praveen : i have doubt in your algo...it seem it may fail for some cases... On Tue, Jan 24, 2012 at 5:59 PM, praveen raj praveen0...@gmail.comwrote: Idea:

Re: [algogeeks] Re: MS Q

2012-01-24 Thread atul anand
@praveen : little more clarity required in your algoare you calling it recursively or moving row by row. On Tue, Jan 24, 2012 at 5:59 PM, praveen raj praveen0...@gmail.com wrote: Idea: 1)Take count =0; 2) make Outer loop ...and search for 1's . 3) Start ...searching for 1

Re: [algogeeks] Re: MS Q

2012-01-15 Thread Umer Farooq
Here is my solution. Please have a look at it. Any kind of positive criticism will be highly appreciated. bool isConnected(int **space, int x, int y) { if (x == 0 y == 0) { return false; } if (y 0) { if (space[x][y-1] == 1) return true; } if (x 0) { if (space[x-1][y] == 1) return true; } if (x

Re: [algogeeks] Re: MS Q

2012-01-11 Thread Ashish Goel
this is the solution that i was referring to in the link i provided. On the same lines there is another problem of rat in a maze . Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jan 11, 2012 at 7:19 AM, Gene gene.ress...@gmail.com wrote:

[algogeeks] Re: MS Q

2012-01-11 Thread Gene
Part of the problem must be rules that specify how 1's can be connected to form an island. From the discussion, it looks like the rules are that a 1 must be connected North, West, East, or South. This is called a 4-connected grid. Another possibility would be an 8-connected grid. This is

[algogeeks] Re: MS Q

2012-01-11 Thread Gene
The OP is not clear on how to handle diagonals. If adjacent 1's on the diagonal are considered connected, then just add 4 more calls to erase(). The standard terms are 4-connected and 8-connected. Both come up when working with grid graphs or pixel matrices. On Jan 10, 9:40 pm, surender sanke

[algogeeks] Re: MS Q

2012-01-10 Thread Gene
Guys, You are making this way too hard. It's really a graph problem. The nodes are the 1's and adjacent 1's are connected by undirected edges. You must count components in the graph. So the algorithm is easy: Find a component, erase it, repeat. Count components as you go. What's an efficient

Re: [algogeeks] Re: MS Q

2012-01-10 Thread surender sanke
@gene in that case ur erase() should even consider diagonal elements as well, else there would be 2 islands in example surender On Wed, Jan 11, 2012 at 7:19 AM, Gene gene.ress...@gmail.com wrote: Guys, You are making this way too hard. It's really a graph problem. The nodes are the 1's and

Re: [algogeeks] Re: MS Q

2012-01-10 Thread prakash y
I think atul/Ramakanth's approach will work fine, if we include one more condition for each arr[i][j] if(arr[i][j]==1) { if (arr[i-1][j]==0 arr[i][j-1]==0 arr[i-1][j-1]==0) count++; else if (arr[i-1][j]==1 arr[i][j-1]==1 arr[i-1][j-1]==0) count--; } On Wed, Jan 11, 2012 at 8:10 AM, surender

Re: [algogeeks] Re: MS Q

2012-01-10 Thread atul anand
@Umer : it has 1 island ashish made editing mistake before. On Wed, Jan 11, 2012 at 11:58 AM, Umer Farooq the.um...@gmail.com wrote: I still don't get how are they two islands. As long as I have understood, diagonals abridge the two islands into one. In this case, these two islands are

[algogeeks] Re: MS Q

2011-06-19 Thread bittu
@harshal every thing seems to be correct m not sure if things will mess up but can we do it in 1 pass ..?? Shashank CSE,BIT Mesra Cracking The Code shashank7s.blogspot.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Re: MS Q

2011-06-19 Thread bittu
@ross i think u mean s[i]==g[b[i]] or s[i]==g[i] then hit++ isn't it u r not using guess at all as u r comparing character with digit correct me if m wrong Shashank CSE,BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] Re: MS Q

2011-06-09 Thread ross
An algorithm is: Have a bit array B of 256/65k size. If an color 'i' is encountered in the solution, set its B[i]=1; Traverse the solution array S, if(S[i]==B[i]) hits++; else if ( B[S[i]] ) pseudohits++; On Jun 10, 9:40 am, Harshal

[algogeeks] Re: MS Q

2011-06-02 Thread Don
Are we drawing a circle on the screen? In addition to Harshal's suggestions, try putting the center off the screen, but have part of the circle on the screen: x=-10 y=-20 r=100 Don On Jun 2, 9:19 am, Ashish Goel ashg...@gmail.com wrote: Given a function to draw a circle with input paramters

Re: [algogeeks] Re: MS Q

2011-06-02 Thread Ashish Goel
while all this is fine, the basic test case that each point on the circle is at a distance of r from the centre becomes first functional test case. what would be non-functional test cases eg. to check on different dpi/screen sizes etc Best Regards Ashish Goel Think positive and find fuel in