farthest from
2: Find a vertex v1 | the farthest form r.
3: Find a vertex v2 | the farthest form v1.
won't v2 be farthest from r? or we are talking about alternate pats also
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Wed, Jun 20, 2012
refer to this link http://www.ics.uci.edu/~eppstein/161/960130.html.
or Using quicksort , it can be done in O(n).
One more way to do this is to make min heap of size-k. Then insert elements
from the original array.If element is greater than root of the heap,swap
them.In the Last, root of the heap
find the element nearest to zero.make it pivot element.then apply one pass
of quicksort over the array.this is O(n)
On Thu, Jun 21, 2012 at 12:27 AM, Akshat Sapra sapraaks...@gmail.comwrote:
void make_group( int a[], int size) {
int j = 0;
for ( int i = 0; i size; i++ ) {
@umer
it's not random,but biased
On Wed, Jun 20, 2012 at 11:16 AM, Umer Farooq the.um...@gmail.com wrote:
Hmmm, true. That's what I expected in this solution. Similarly, we can get
3 by (3,3) (1,2)
However, did you take a look at the other solution I proposed? I guess
that solves the
in this prob also
for i=0, i to k
read cand
rem=(rem+cand)%k
if (rem) then no
else yes
--
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
my code is running perfectly well but giving WA in spoj..
#includestdio.h
#includestdlib.h
int main()
{
int cand,sum;
int T,N,i,j,temp[10];
scanf(%d,T);
sum = 0;
for(i=0;iT;i++)
{
scanf(%d,N);
for(j=0;jN;j++)
{
scanf(%d,cand);
i think you should try to give output for each test case rather to use any
temp array
--
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
@Abhi: if you apply quick sort then again the order will will not be intact
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/ic2CXJXSGuoJ.
To post to this
@akshat ur code doesn't give intact output, so i modified ur code and
here is the code :
int j=0,k=0;
for (i = 0; i n; ++i)
{
if(a[i]0)
{
a[j] = a[i];
j++;
}
else
{
temp[k] = a[i];
k++;
}
}
k=0;
for (i = j; i n; ++i)
{
These posts will clear ur questions
http://www.geeksforgeeks.org/archives/12367
http://www.geeksforgeeks.org/archives/12615
--
ATul Singh | Computer Science Engineering| 2008-12 Batch | NIT Jalandhar
| 9530739855
--
You received this message because you are subscribed to the Google Groups
Krishna,
how can you store a address pointing to k bits value into k/2 bits? XOR
is the way to do this.
--
Amitesh
On Thu, Jun 21, 2012 at 1:20 AM, Krishna Kishore
kknarenkris...@gmail.comwrote:
*np *is nothing but *next_pointer. np[x] *does mean *x-np *which is the
next pointer to
here is my code :
#includestdio.h
#includestdlib.h
int main()
{
long long cand,sum;
int T,N,i,j,*temp;
scanf(%d,T);
temp= (int*)calloc(T, sizeof( int));
sum = 0;
for(i=0;iT;i++)
{
scanf(%d,N);
for(j=0;jN;j++)
{
scanf(%lld,cand);
guys this is my solution to the problem, it's a bit sloppy but as far as I
checked it was working please have a go at it?
#include stdio.h
#include stdlib.h
int main() {
int arr1[] = {0,-5,3,0,4,-6,-9};
int arr2[7];
int j = 0;
for ( int i = 0 ; i 7 ; i++ ) {
//loop for
can this be done in single pass in O(n) .
On Thu, Jun 21, 2012 at 8:10 PM, rusty dafc1...@gmail.com wrote:
guys this is my solution to the problem, it's a bit sloppy but as far as I
checked it was working please have a go at it?
#include stdio.h
#include stdlib.h
int main() {
Initialize sum as zero for all test cases ie inside 1st for loop.
On Jun 21, 2012 5:22 PM, Mayank Singh singh13490may...@gmail.com wrote:
here is my code :
#includestdio.h
#includestdlib.h
int main()
{
long long cand,sum;
int T,N,i,j,*temp;
scanf(%d,T);
temp=
Can't we use k iterations of bubble sort ?
On Jun 18, 2012 2:11 PM, Ramindar Singh ramin...@gmail.com wrote:
We can use Median of medians
http://en.wikipedia.org/wiki/Selection_algorithm#Linear_general_selection_algorithm_-_Median_of_Medians_algorithm
On Sunday, 17 June 2012 08:13:18
@Mayank coding style not seems gud.. try this...
int main()
{
int testCases;
scanf(%d,testCases);
while(testCases--0)
{
//perform ur logic
//print output for each test case here instead of storing it into
an array.
}
}
return 0;
}
On Thu, Jun 21, 2012 at 10:35 PM,
it seems @hassan sol is correctcan nybody knw d flaw in it???
--
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
@ashish it wont be...first we r finding one end from any node dat is r n
den frm dat end we r traversing to other deepest end...
it is possible dat r b d intermediate node...n distance from r to v2 is
smaller than from r to v1
--
You received this message because you are subscribed to the Google
single traversal n O(n) are 2 diff things...plz specify???
--
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
The reason why finding a solution to this question is difficult is because
the combinations of rand5() function which we use ( eg. rand5() + rand5()%2
) leads to some numbers being generated more frequently than others. So the
problem would be solved if we could find a function which leads to each
@ Anant Sharma
Good one. it should work .
On Thu, Jun 21, 2012 at 9:43 PM, Anant Sharma black.b...@gmail.com wrote:
The reason why finding a solution to this question is difficult is because
the combinations of rand5() function which we use ( eg. rand5() + rand5()%2
) leads to some numbers
Well they are the same you're going over an array once. As long as they are
not nested they are still counted as O(n) because leading constants are
dropped, at least that's what my acumen says. Need inputs on this guys!
On Friday, June 22, 2012 12:53:02 AM UTC+5:30, suzi wrote:
single
i have a doubt ... is the range of rand7 from 0 to 6 or from 1 to 7
On Fri, Jun 22, 2012 at 10:13 AM, Anant Sharma black.b...@gmail.com wrote:
The reason why finding a solution to this question is difficult is because
the combinations of rand5() function which we use ( eg. rand5() + rand5()%2
i mean o(n) in single traversal .
On Fri, Jun 22, 2012 at 12:53 AM, sanjay pandey
sanjaypandey...@gmail.comwrote:
single traversal n O(n) are 2 diff things...plz specify???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
@ sohinee basak
it won't matter much . +1 or -1 will get u right range.. : ...
On Thu, Jun 21, 2012 at 9:54 PM, sohinee basak sohine...@gmail.com wrote:
i have a doubt ... is the range of rand7 from 0 to 6 or from 1 to 7
On Fri, Jun 22, 2012 at 10:13 AM, Anant Sharma black.b...@gmail.com
26 matches
Mail list logo