is O(long n!)
n! is O(n^n) by sterling approximation
hence it is O(log n^n) = O(nlogn)
On Sun, Oct 28, 2012 at 11:14 PM, Pralay Biswas
pralaybiswas2...@gmail.comwrote:
@ Siddharth :
Well, here is how you may understand it:
1) There is an outer loop that runs n times. (k)
2) Then there is an
use pascal's triangle
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
string str;
while(cin str)
{
cout str endl;
}
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
@bharat: When each step of nishant's algo is O(n) how can it sum up to
O(nlogn)???
On Tue, Sep 13, 2011 at 9:18 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
@nishant : your algo takes O(nlogn) time with higher constant behind
this. can't we write better than this ?
@sairam
With hashing..
make a hash table of elements from 0 to sum/2
if an element k is in sum/2 to sum then check if sum-k is in the hashtable.
take care of the case when sum is even and sum/2 occurs only once.
TC: O(n) Space complexity: O(sum)
Method2: Sort the elements.
Now maintain to pointers one at
@Neha take 42, 21 and 1
42 ^ 1 =43
while 42 ^21 =63
On Fri, Aug 26, 2011 at 10:28 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote:
Sort the nos., which can be done in O(nlogn)
Now the 1st and the last integers are the required integers.
--
You received this message because you are
Hi hary,
when do you think that there can be problem? The sq is never made to store a
value 10^9 (for previous sq) +9*10^9 (for new sum)
hence the sum never exceeds 10^10 which is under the range of int.
Correct me if i go wrong somewhere.
On Thu, Apr 28, 2011 at 12:26 PM, hary rathor
sort two of the list and pick one number in C(unsorted) to find if there
exists a pair with the sum.
This can be done in linear time by maintaining two pointers.
Hence O(n^2).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
amazom needs 7*4=28 bytes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
@Dave: Sorry It was a typo but for the probability figures,
When C shoots B then if he is successful then A will shoot C
Hence he must be unsuccessful and then
if B is unsuccessful then A must will Kill B and then C must kill A
if B is successful then C must kill B now
Hence P(when C shoots at
@swayambhoo:
ofcourse a cubical room must me symmetrical at allcorners, Hence, neway it
will reach in
min_dis=sqrt((4+3)^2+5^2)=8.6
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
For n x m take first element of all the rows and insert in a min heap.
Now take the smallest element and and if we have a track of from which row
it belongs, we can take an element out of that row
and insert in the heap.
this will be done n x m times. Hence we have a time complexity of
O(nmlog(m))
for each element in the second array apply binary search in first array. ie,
For X[1] find 1 in first array with binary search.
Time Complexity=O(nlogn)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
make another array(B) from (A) with all elements negated
now find one element from B and one from A whose sum is x or -x. This can
ofcourse be done in O(n).
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Algo:
In first traverse find the min and the max values.
if (max-min) not equals (N-1)
return false
In next traverse map each in a hashtable of size N where index=key-min. Now
in case of collision return false
return true
--
You received this message because you are subscribed to the Google
rem=1;
for(j=3;j=N+1;j++)
rem=(rem*j)%n;
return rem;
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
@coolfrog
the question never asked u to find thm in order of thier distances.
Correct me if i m wrong!
find the distances in O(n)
now using the partitioning process of quicksort.
Dividing the array into two parts:
Now if the Length of the first part is less than or equal to i we have to
now make
#includestdio.h
int main()
{
int arr[11]={0},sum2[1001]={0};
int type[1001]={0};//0 for tails
int N,Q,i,j,sum;
int a,b,c;
scanf(%d,N);
scanf(%d,Q);
for(i=0;iQ;i++)
{
scanf(%d%d%d,a,b,c);
if(a==0)
{
j=b;
int
@fenghuang: the last step will take O(n logn ) . Or there is some better
way?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
will O(n) work or u wish something lesser dependent on k or log(n) ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
result=((n ((128)/3))1)|((n ((129)/3))1);
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
21 matches
Mail list logo