gXa's blog

By gXa, history, 9 years ago, In English

Can someone please help me to solve this using recursion tree method, I am trying it but unable to solve it. T(N) = sqrt( N ) T( sqrt( N ) ) + sqrt( N )

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

We have designed an new algorithm to sort a list of n numbers. We recursively partition the numbers into groups of size sqrt(n) each until we are left with lists of constant size; at which point we use insertion sort to sort the numbers. To combine solutions, we do a merge of the sorted lists, namely maintaining pointers to the start of the list and at each step advancing the pointer of the list corresponding to the smallest element. Let T(n) denote the running time of this algorithm (we can assume that sqrt(k) is an integer for all k<=n encountered in the algorithm).

Running time : T(n) <= sqrt(n) T( sqrt(n) ) + O(n^1.5)

I can think of it as T(n) = T( sqrt(n) ) + T( n-sqrt(n) ) + O(n) but can't relate to the solution. Plz can anybody explain its running time.

Full text and comments »

  • Vote: I like it
  • -13
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

Can anybody plz explain why the upper bound of n in problem Primes or Palindromes? is 10^7. I have spent a whole day but coul not figure out. Plz can someone explain rigourously.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

Why this compiles: Plz guide me on this:

int main() {

for(int i = 0; 0; i++) {

cout<<"H"; }

}

Can u elaborate the working of this code?

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

In java 8, all the commands of java 7 work or not.

I am asking this question because in c++ 11 #define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();++it) does not work while in c++4.9.2 it works.

So I wanted to know which one is better java 8 or 7 and if java 8 then all commands of java 7 work on it or not. Plz help me in this.

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

If N and M are used as double, then for comparing them, can we do this:

if( N<=M ) { cout << "Yes"; }

If not then suggest what to do?

If N is long long and M is double, then for comparing them, can we do this:

if( N<=M ) { cout << "Yes"; }

If not then suggest what to do?

Comparison with double is causing me problem. So guide me what to do?

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

Can anybody plz ezplain:

for(int i = 1; i <= n; i++) { scanf("%s", a[i] + 1); }

I know this one

for(int i = 1; i <= n; i++) { scanf("%s", a[i] ); }

But I don't know the use of above scanf("%s", a[i] + 1); Plz guide me on this.

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it

By gXa, history, 9 years ago, In English

Can someone please explain me lower_bound and upper_bound and how they are used in sorted array? Please explain in depth.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it