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
Use 2 semaphores.
pseudo code
sem_1(1);
sem_2(0);
THREAD A;THREAD B
sem_1_wait(); sem_2_wait();
...
sem_2_signal();
#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
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
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:
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