[algogeeks] Re: Facebook Campus Test Question

2011-11-04 Thread Dumanshu
plz post a samle input output.. On Nov 4, 10:24 am, sunny agrawal sunny816.i...@gmail.com wrote: What can be a better solution than a Brute Force O(N^2* No of iteration) -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee  fb1_input.txt 1KViewDownload  

Re: [algogeeks] Re: Facebook Campus Test Question

2011-11-04 Thread sunny agrawal
i/p o/p files are attached in the post, see carefully :-o On Fri, Nov 4, 2011 at 6:23 PM, Dumanshu duman...@gmail.com wrote: plz post a samle input output.. On Nov 4, 10:24 am, sunny agrawal sunny816.i...@gmail.com wrote: What can be a better solution than a Brute Force O(N^2* No of

[algogeeks] Social graph labeling

2011-11-04 Thread mohit verma
Hi guys, Social sites like facebook or linkedin must be having some vertex labelling techniques. I cant' imagine what labelling they use since there are trillions of nodes in there network ( coz simple integer or alphanumeric labelling will not be efficient enough as far as i think). Can someone

[algogeeks] Re: Facebook Campus Test Question

2011-11-04 Thread Dumanshu
is ur brute force O(1) for space? On Nov 4, 10:24 am, sunny agrawal sunny816.i...@gmail.com wrote: What can be a better solution than a Brute Force O(N^2* No of iteration) -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee  fb1_input.txt 1KViewDownload  

Re: [algogeeks] Re: Facebook Campus Test Question

2011-11-04 Thread sunny agrawal
No,O(N^2) because all the flips happens simultaneously, it can be reduce to O(2N) if each tile is represented using a single bit On Fri, Nov 4, 2011 at 11:12 PM, Dumanshu duman...@gmail.com wrote: is ur brute force O(1) for space? On Nov 4, 10:24 am, sunny agrawal sunny816.i...@gmail.com

[algogeeks] Re: Median of 2D matrix

2011-11-04 Thread Gene
Here's an idea. Say we pick any element P in the 2D array A and use it to fill in an N element array X as follows. j = N; for i = 1 to N do while A(i, j) P do j = j - 1; end; X(i) = j; end; This algorithm needs O(N) time. The elements of X split each row with respect to P. That is,

Re: [algogeeks] Re: Median of 2D matrix

2011-11-04 Thread mohit verma
I think this can be done in O(n) time simply by finding the median of elements at DIAGNOL starting from right corner to left corner. Coz as elements are sorted row-wise and column-wise , it implies that elements below this diagonal are all greater than elements on this diagonal and all above this

[algogeeks] Re: Median of 2D matrix

2011-11-04 Thread ankit agarwal
Hi, I think the median will always lie on the diagonal a[n][1] a[1][n] because the elements on the LHS making the upper triangle will always be less than or equal to the elements on the diagonal and the RHS, elements in the lower triangle will be greater than or equal to them. so sort the