oh, understood, i thought it takes constant time suppose if it takes,
then is there any benefit of this recursion compared to
reverse(str) = str[lastcharacter] + reverse(str(0, last-1))
it will reduce the recursion depth right ? No gain on time complexity though
a small correction, btw, T(n)
it is same as merge sort working procedure as atul said.
On Tue, Nov 27, 2012 at 12:48 PM, atul anand wrote:
> considering '+' , here will take Cn time . Here '+' is for concatenate ,
> now this concatenation taking place in constant time?? , i dont think
> so..internally it will be adding elemen
considering '+' , here will take Cn time . Here '+' is for concatenate ,
now this concatenation taking place in constant time?? , i dont think
so..internally it will be adding elements to new m/m space and for that it
need to traverse each character...so it will take cn time.
so T(n) =T(n/2) + cn =
hi @all:
i am little bit confused on the discussion going here on this thread..
largest subset sum problem in computer science is NP complete as followed
http://en.wikipedia.org/wiki/Subset_sum_problem
also in book written by CLRS in chapter 35.5 i have found that "The
decision problem ask whether
This is an implementation-specific issue, and will vary between
languages and container libraries. Some responders have mentioned that
vectors are synced, which makes them slower. That's true in Java. Not
true in C++. Certainly not true in C. The only way to know for sure
which is faster is to run
Thanks all for the response.
I thought of constructing a conditional wait using semaphores as follows:
//global flag = 0.
void *text(void *arg)
{
int n = *(int*)arg;
while(flag != n)
{
sem_wait(&mutex);
internal_flag = 1;
}
if(internal_flag)
sem_post(&mutex);
..