I'm sorry. Maybe you don't get the question. Your method is used to find
the nearest C to A and B, but we need to find C such that the distance from
C to A and B are as *large* as possible.
Thank you for your response, I really appreciate that. And I'm looking
forward to getting more ideas from
Root the tree at an arbitrary node and preprocess the tree using heavy
light decomposition.
For each query (A,B), find C = LCA(A,B) (It can be done in O(log n) time
now.),
now the required answer is min(level(A), level(B)) - level(C).
On Sun, Jan 13, 2013 at 7:43 AM, Danh Nguyen
Hi everyone,
I'm trying to solve this problem, but I have no idea to
beginhttp://discuss.codechef.com/questions/5069/tree-again#.
I really need some hints for it:
-
Given a tree of N nodes, and Q queries. (1 = N, Q = 100,000)
-
Each query has 2 arbitrary nodes on that
Ohhh... Sorry sorry... silly question... Was thinking complexly :(
On Tue, Nov 22, 2011 at 1:28 PM, Anika Jain anika.jai...@gmail.com wrote:
yes..
On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote:
Can a function return a void pointer ?
--
You received this message
Ignore the previous post.. Was meant for some other post :)
On Tue, Nov 22, 2011 at 1:39 PM, saurabh koar koarsaur...@gmail.com wrote:
Ohhh... Sorry sorry... silly question... Was thinking complexly :(
On Tue, Nov 22, 2011 at 1:28 PM, Anika Jain anika.jai...@gmail.comwrote:
yes..
On Tue,
ya
void * malloc(void * ptr)
since void * is generic pointer,it can converted to pointer of any type and
vice versa
On Tue, Nov 22, 2011 at 1:28 PM, Anika Jain anika.jai...@gmail.com wrote:
yes..
On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote:
Can a function return a
Yes
Functions returning void pointers are generally used for generic
programming.
--
Thanks and Regards
*Devansh Gupta*
*B.Tech Third Year*
*MNNIT, Allahabad*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
Can a function return a void pointer ?
--
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
Ofcrse yes... hvnt you use Malloc ??
On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote:
Can a function return a void pointer ?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
yes..
On Tue, Nov 22, 2011 at 1:23 PM, Aniket aniket...@gmail.com wrote:
Can a function return a void pointer ?
--
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
#includestdio.h
void fac(int a)
{
if(a=0)
{
printf(%d\n,a);
fac(a-=5);
}
if(a=0)printf(%d\n,a);
}
main()
{
fac(15);
}
On Wed, Aug 31, 2011 at 11:09 AM, Dheeraj Sharma
dheerajsharma1...@gmail.com wrote:
int num=15 //global variable
void fun()
{
if(num=0)
{
printf(0\n);
return;
}
had microsoft came in nit kurukshetra in last weekif yes then guys
from nit kurukshetra plz tell there procedure n questions???thnx in
advance guys
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Test hua h bas
--
Parag Khanna
B.tech Final Year
NIT,Kurukshetra
--
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
yeah it came yesterday..the paper was very easy
1.u have to find loop in linked list..
2.u are given a number..you have to print it down to zero(subtracting 5) and
then print from 0 to that number(adding 5) without using local variables.
3.two C questions ..that were very easy..
4.Print the sum of
can u pls tell me the answer for the 2nd question..
On Tue, Aug 30, 2011 at 12:04 PM, Dheeraj Sharma
dheerajsharma1...@gmail.com wrote:
yeah it came yesterday..the paper was very easy
1.u have to find loop in linked list..
2.u are given a number..you have to print it down to
int num=15 //global variable
void fun()
{
if(num=0)
{
printf(0\n);
return;
}
printf(%d\n,num);
num-=5;
fun();
num+=5;
printf(%d\n,num);
}
On Wed, Aug 31, 2011 at 10:59 AM, bharatkumar bagana
bagana.bharatku...@gmail.com wrote:
can u pls tell me the answer for the 2nd question..
On Tue,
@ gopi:
I think you are referring to the even number of elements in the list.
Anyhow, here is the solution to the odd number of elements.
http://ideone.com/5nmzL
Now is the problem solved?
On 20 August 2011 10:47, *$* gopi.komand...@gmail.com wrote:
Hi,
But as per the given problem , that
Its the same as we do merge sort where we merge the two sorted array into
one which will require an extra array..
Is there any algorithm for inplace mergesort...?
On Fri, Aug 19, 2011 at 2:09 PM, sagar pareek sagarpar...@gmail.com wrote:
Can be done in O(n) time but it will need O(n) space
this was earlier in this group...
Please see this paper: http://j.mp/rtNp4W
On Fri, Aug 19, 2011 at 2:40 PM, Abhishek Yadav abhishek30.nit...@gmail.com
wrote:
Its the same as we do merge sort where we merge the two sorted array into
one which will require an extra array..
Is there any
http://ideone.com/ucO4d
Total no. of elements should be even (I assume) and it is also failing for
some test cases. Working on to zero down to the error in algo.
On 20 August 2011 02:11, JAIDEV YADAV jaid...@gmail.com wrote:
this was earlier in this group...
Please see this paper:
Fixed the problem. There was a problem with the first element positioning.
Here is the final solution:
http://ideone.com/XwymV
^^ Time complexity - O(2n)
Space complexity O(1)
:)
On 20 August 2011 08:14, Dipankar Patro dip10c...@gmail.com wrote:
http://ideone.com/ucO4d
Total no. of elements
Hello all
I have just joined the group and I am happy that I took this decision..:)
However I want to direct all the mails from the group to another id that I
made specifically for this group..but it is not showing the email id in the
drop down box in the setting ...Please help
Cosmexia
On
Hi,
But as per the given problem , that constraint is not specified..
thx,
--Gopi
On Sat, Aug 20, 2011 at 9:25 AM, Dipankar Patro dip10c...@gmail.com wrote:
Fixed the problem. There was a problem with the first element positioning.
Here is the final solution:
http://ideone.com/XwymV
^^
Sort an array of n positive integers containing n/2 sorted integers in first
and second-half?
in O(n) time complexity ..
and space complexity should be constant
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
Could anyone please explain me how this query selects the employee
with nth highest salary?
select last_name, salary from employees e1
where n = (select count(distinct(salary)) from employees e2
where e2.salary = e1.salary);
--
You received this message because you are subscribed to the Google
select top 1 salary from(select top 6 salary from employee
order by salary desc)asc
On Sat, Aug 6, 2011 at 6:40 PM, Reynald reynaldsus...@gmail.com wrote:
Could anyone please explain me how this query selects the employee
with nth highest salary?
select last_name, salary from employees e1
Because u copied the code i think :P
try writing printf statement yourself again :)
On Wed, Jun 29, 2011 at 5:05 PM, Anika Jain anika.jai...@gmail.com wrote:
int main()
{
int I =10, j=2;
int *ip = I ,*jp =j;
int k = *ip/ *jp;
printf(“%u”,k);
return 0;
}
in this
hey, printf(%d ya %u in both same error cming..
On Wed, Jun 29, 2011 at 5:10 PM, sunny agrawal sunny816.i...@gmail.comwrote:
Because u copied the code i think :P
try writing printf statement yourself again :)
On Wed, Jun 29, 2011 at 5:05 PM, Anika Jain anika.jai...@gmail.comwrote:
int
the error is in quotes, just rewrite them
On Wed, Jun 29, 2011 at 5:24 PM, Anika Jain anika.jai...@gmail.com wrote:
hey, printf(%d ya %u in both same error cming..
On Wed, Jun 29, 2011 at 5:10 PM, sunny agrawal sunny816.i...@gmail.comwrote:
Because u copied the code i think :P
try
Its working fine..
On Wed, Jun 29, 2011 at 5:26 PM, sunny agrawal sunny816.i...@gmail.comwrote:
the error is in quotes, just rewrite them
On Wed, Jun 29, 2011 at 5:24 PM, Anika Jain anika.jai...@gmail.comwrote:
hey, printf(%d ya %u in both same error cming..
On Wed, Jun 29, 2011 at
Piyush the original code has double apostrophe( ' ) instead of inverted
comma's.
http://ideone.com/zPpGA
On Wed, Jun 29, 2011 at 5:30 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
Its working fine..
On Wed, Jun 29, 2011 at 5:26 PM, sunny agrawal sunny816.i...@gmail.comwrote:
the error is
ya noticed just now when sunny agrawal pointed it out...
On Wed, Jun 29, 2011 at 5:38 PM, oppilas . jatka.oppimi...@gmail.comwrote:
Piyush the original code has double apostrophe( ' ) instead of inverted
comma's.
http://ideone.com/zPpGA
On Wed, Jun 29, 2011 at 5:30 PM, Piyush Sinha
we carefull..
there is no space between / *
i.e In question it is written as /*. which denote the behaviour of
multiline comment it is not end with */
So this is the error
if I m wrong then Please correct me
--
You received this message because you are subscribed to the Google Groups
yup arjoo is ryt... error is bcoz of ' /* ' only ... compiler treats it as
the start of the comment.. but there is no end hence the error
On Wed, Jun 29, 2011 at 7:24 PM, arjoo kumar 2009ar...@gmail.com wrote:
we carefull..
there is no space between / *
i.e In question it is written as
@Vaibhav: Sunny is also right bcz if u jst copy n paste d above code with (/
*jp) it'll show an error... And the error is in printf statement. jst cut it
from the program n thn write it again.. It'll wrk properly
--
You received this message because you are subscribed to the Google Groups
I have just copied ans pasted the code of OP.
And changed .
http://codepad.org/rBnx7z8V
On Wed, Jun 29, 2011 at 8:17 PM, udit sharma sharmaudit...@gmail.comwrote:
@Vaibhav: Sunny is also right bcz if u jst copy n paste d above code with
(/ *jp) it'll show an error... And the error is in
int NumberOfSetBits(int i)
{
i = i - ((i 1) 0x);
i = (i 0x) + ((i 2) 0x);
return ((i + (i 4) 0xF0F0F0F) * 0x1010101) 24;
}
This is the code in order to count the number of set bits.Can any one
explain me how the instructions in this code can be
37 matches
Mail list logo