[algogeeks] absolute minimum difference

2012-07-27 Thread Navin Kumar
Given array of integers (0 or +ve or -ve value) find two elements having minimum difference in their absolute values. e.g. Input {10 , -2, 4, 9,-20,17,-8,14,12) output {9,-8} I have solved it in O(nlogn). can it be solved in O(n). -- You received this message because you are subscribed to the

Re: [algogeeks] Re: Queue problem

2012-07-27 Thread Hariraman R
Single queue only satisfies the given condition. I think it's the correct one.. -- 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] Fwd: general tree into BST

2012-07-27 Thread Sathish babu
**~Sathish Babu~** -- Forwarded message -- From: Sathish babu satbrucei...@gmail.com Date: Wed, Jul 25, 2012 at 9:52 PM Subject: general tree into BST To: algogeeks@googlegroups.com Hey hi, can anyone provide the code to convert general tree into BST and BST into general

[algogeeks] Help for Indus Valley partners!

2012-07-27 Thread s_m154
Can you please tell the kind of algos that will be asked for the interview and what all subjects to focus for? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks]

2012-07-27 Thread Abhishak Kapoor
thanks for the code. On Wednesday, July 25, 2012 7:29:36 PM UTC+5:30, Navin Kumar wrote: logic is very simple ...just trace the program you will understand. On Wed, Jul 25, 2012 at 7:28 PM, Navin Kumar algorithm.i...@gmail.comwrote: #include stdio.h #include stdlib.h #include ctype.h

Re: [algogeeks] Java recursion Question !!

2012-07-27 Thread teja bala
thx alot How silly my mistake was!! :( ... On Thu, Jul 26, 2012 at 11:16 PM, payal gupta gpt.pa...@gmail.com wrote: perhaps its this quoted line... permu(c,i+1,j); permu(c,i+1,n) On Thu, Jul 26, 2012 at 9:37 PM, teja bala pawanjalsa.t...@gmail.comwrote: // plz anyone tell

Re: [algogeeks] Programming Problem

2012-07-27 Thread Priya Dhingra
@ ashish the example which you given here ie aaab and at the end you said that ba is the beautiful string how com ba can be derived or produced from aaab becoz as per the definition String s2 is *producible* from string s1, if we can remove some characters of s1 to obtain s2. and ba sequence

[algogeeks] what will be output for this program ?

2012-07-27 Thread Hraday Sharma
#includestdio.h int main(){ printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); return 0; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this

[algogeeks] Re: absolute minimum difference

2012-07-27 Thread s_m154
Can you please give the algo of solving it in O(nlogn) On Friday, 27 July 2012 15:35:24 UTC+5:30, Navin Kumar wrote: Given array of integers (0 or +ve or -ve value) find two elements having minimum difference in their absolute values. e.g. Input {10 , -2, 4, 9,-20,17,-8,14,12) output {9,-8}

[algogeeks] Re: absolute minimum difference

2012-07-27 Thread s_m154
and just for confirming.. will the algo for O(n2) be: // uses kind of selection sort technique mindiff = abs(a[1]-a[2]) //take a default min value for i= 1 to n for j= 1 to n if i==j // same no. continue if abs(a[i]-a[j]) mindiff // if difference of some other

[algogeeks] Re: absolute minimum difference

2012-07-27 Thread Dave
@s_m154: Sort the array in O(n log n) and then compare adjacent numbers to find the closest pair in O(n). Total: O(n log n). Dave On Friday, July 27, 2012 10:41:28 AM UTC-5, s_m154 wrote: Can you please give the algo of solving it in O(nlogn) On Friday, 27 July 2012 15:35:24 UTC+5:30,

Re: [algogeeks] what will be output for this program ?

2012-07-27 Thread rahul aravind
64 32 16 32 16 32 64 32 On Fri, Jul 27, 2012 at 6:48 PM, Hraday Sharma hradaysha...@gmail.comwrote: #includestdio.h int main(){ printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); printf(%d %d\n, 321, 320); printf(%d %d\n, 32-1, 32-0); return 0; -- You

Re: [algogeeks] Re: absolute minimum difference

2012-07-27 Thread Arun Kindra
@Dave Sir : Sir if u sort the array(given above) the array would be: -20,-8-2,4,9,10,12,14,17, and according to ur suggestion, the only ans is {9,10}...but one of the ans {9,-8} is also possible...as he is asking the difference in absolute values. correct me if i m wrong... -- You received

Re: [algogeeks] what will be output for this program ?

2012-07-27 Thread Arun Kindra
compiler dependent -- 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

Re: [algogeeks] Re: absolute minimum difference

2012-07-27 Thread Dave
@Arun: I left out that you sort the array by absolute values and compare absolute values of adjacent elements. The sorted array would be {-2, 4, -8, 9, 10, 12, 14, 17, -20}. Then abs(abs(-8) - abs(9)) is the smallest difference. Dave Dave On Friday, July 27, 2012 11:21:52 PM UTC-5, Arun