Re: [algogeeks] Query on a tree again!

2013-01-18 Thread Nguyễn Thành Danh
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

Re: [algogeeks] Query on a tree again!

2013-01-16 Thread rizwan hudda
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

[algogeeks] Query on a tree again!

2013-01-15 Thread 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

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread saurabh koar
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

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread saurabh koar
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,

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread Akash Coder
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

Re: [algogeeks] Query: Function returning void pointer

2011-11-22 Thread DeVaNsH gUpTa
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

[algogeeks] Query: Function returning void pointer

2011-11-21 Thread Aniket
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

Re: [algogeeks] Query: Function returning void pointer

2011-11-21 Thread Prem Krishna Chettri
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

Re: [algogeeks] Query: Function returning void pointer

2011-11-21 Thread Anika Jain
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

Re: [algogeeks] query for nit kurukshtra students

2011-08-31 Thread teja bala
#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; }

[algogeeks] query for nit kurukshtra students

2011-08-30 Thread rahul sharma
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

Re: [algogeeks] query for nit kurukshtra students

2011-08-30 Thread parag khanna
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

Re: [algogeeks] query for nit kurukshtra students

2011-08-30 Thread Dheeraj Sharma
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

Re: [algogeeks] query for nit kurukshtra students

2011-08-30 Thread bharatkumar bagana
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

Re: [algogeeks] query for nit kurukshtra students

2011-08-30 Thread Dheeraj Sharma
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,

Re: [algogeeks] query.. amazon question

2011-08-20 Thread Dipankar Patro
@ 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

Re: [algogeeks] query.. amazon question

2011-08-19 Thread Abhishek Yadav
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

Re: [algogeeks] query.. amazon question

2011-08-19 Thread JAIDEV YADAV
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

Re: [algogeeks] query.. amazon question

2011-08-19 Thread Dipankar Patro
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:

Re: [algogeeks] query.. amazon question

2011-08-19 Thread Dipankar Patro
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

Re: [algogeeks] query.. amazon question

2011-08-19 Thread Anushruti Gupta
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

Re: [algogeeks] query.. amazon question

2011-08-19 Thread *$*
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 ^^

[algogeeks] query.. amazon question

2011-08-18 Thread *$*
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

[algogeeks] Query to find the Nth highest salary in employee table

2011-08-06 Thread Reynald
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

Re: [algogeeks] Query to find the Nth highest salary in employee table

2011-08-06 Thread coder dumca
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

Re: [algogeeks] query

2011-06-29 Thread sunny agrawal
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

Re: [algogeeks] query

2011-06-29 Thread Anika Jain
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

Re: [algogeeks] query

2011-06-29 Thread sunny agrawal
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

Re: [algogeeks] query

2011-06-29 Thread Piyush Sinha
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

Re: [algogeeks] query

2011-06-29 Thread oppilas .
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

Re: [algogeeks] query

2011-06-29 Thread Piyush Sinha
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

Re: [algogeeks] query

2011-06-29 Thread arjoo kumar
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

Re: [algogeeks] query

2011-06-29 Thread vaibhav shukla
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

Re: [algogeeks] query

2011-06-29 Thread udit sharma
@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

Re: [algogeeks] query

2011-06-29 Thread oppilas .
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

[algogeeks] Query to count set bits

2011-06-23 Thread Vivek Srivastava
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