Re: [algogeeks] About suffix trees and suffix arrays

2011-11-08 Thread Shreyas VA
Check out Ukkonen's algorithm. You can build a suffix tree in O(n). Good stuff. I would start there On Tue, Nov 8, 2011 at 10:41 PM, kumar raja rajkumar.cs...@gmail.comwrote: I have studied about it ,but could not understand why their construction is in linear time and support so many

Re: [algogeeks] doubt???

2011-09-28 Thread Shreyas VA
Use 2 semaphores. pseudo code sem_1(1); sem_2(0); THREAD A;THREAD B sem_1_wait(); sem_2_wait(); ... sem_2_signal();

Re: [algogeeks] Facebook Interview question at NIT Warangal

2011-07-26 Thread Shreyas VA
#include bitset #include iostream #include math.h #include vector int main() { using namespace std; int arr[] = {1,2,3,4}; int k = 2; int n = sizeof(arr)/sizeof(int); vectorint v(arr, arr+n); int l = pow(2.0, n); for (int i = 0; i l; ++i) { bitset32 b(i); if (b.count() != k) continue; for (int j

Re: [algogeeks] sort partially sorted linked list

2011-03-02 Thread Shreyas VA
I think in this case bubble sort with early exit will be efficient On Wed, Mar 2, 2011 at 8:16 PM, snehal jain learner@gmail.com wrote: The LL is in alternating ascending and descendin orders. Sort the list efficiently egs: 1-2-3-12-11-2-10-6-NULL -- You received this message because

Re: [algogeeks] Microsoft interview question

2010-12-04 Thread Shreyas VA
Given the size of the input array, construct array1 = {0, 1, 0, 1} till n elements traverse through input array checking sum of 1's n 0's. at the end if both sums are equal return array1 else return input array. On Sat, Dec 4, 2010 at 12:06 AM, siva viknesh sivavikne...@gmail.comwrote:

Re: [algogeeks] Microsoft interview question

2010-12-04 Thread Shreyas VA
My bad, did not see the in-place memory requirement On Sat, Dec 4, 2010 at 8:49 PM, coolfrog$ dixit.coolfrog.div...@gmail.comwrote: @shreyas VA you are using O(n) extra space... On Sat, Dec 4, 2010 at 8:46 PM, Shreyas VA v.a.shre...@gmail.com wrote: Given the size of the input array