[algogeeks] Maximum size binary search tree

2010-06-23 Thread Raj N
Find the maximum size Binary search tree in a binary tree?? -- 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] Maximum number of collinear points

2010-06-23 Thread Raj N
In a plane given n points (x1,y1) (x2,y2)(xn,yn), find the the maximum number of collinear points. -- 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

[algogeeks] Next higher element

2010-06-23 Thread Raj N
Design a data structure to find the next higher element for each element in an array. For e.g. if array is 1 2 3 4 5 8 6 o/p should be (element) (next higher element) 1 2 2 3 3 4 4 5 5 8 8 nothing 6 nothing The array need not be sorted. Constraints-O(n) time complexity -- You received this

[algogeeks] triplets summing to zero

2010-06-23 Thread Raj N
Given a list of n integers?(negative and positive), not sorted and duplicates allowed, you have to output the triplets which sum upto 0. -- 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] Re: Swap the bits

2010-06-23 Thread manisha nandal
char a=10 01 11 01 a = a ^ ~ ( 0 ) //now a is 01 10 00 10 -- 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] Re: Swap the bits

2010-06-23 Thread Dave
Manisha, this is not the desired result. -- Dave On Jun 23, 6:26 am, manisha nandal manisha04.nan...@gmail.com wrote: char a=10 01 11 01 a = a ^ ~ ( 0 ) //now a is 01 10 00 10 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] Maximum subset of cuboid boxes

2010-06-23 Thread Raj N
Given a lot of cuboid boxes with different length, breadth and height. We need to find the maximum subset which can fit into each other. For example: If Box 1 has LBH as 7 8 9 If Box 2 has LBH as 5 6 8 If Box 3 has LBH as 5 8 7 If Box 4 has LBH as 4 4 4 then answer is 1,2,4 A box can fit into

Re: [algogeeks] 23 candies among 7 kids

2010-06-23 Thread harit agarwal
it is 29! / 23! -- 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, visit

Re: [algogeeks] Next higher element

2010-06-23 Thread Kumar Vishal
hi the number should be just next higher element or any higher element like if my arr is like arr= 2 5 1 3 7 6 the next higher element for 5 should be what (7 or 6 ) because 6 is more closer to 7 but 7 comes first in arr On Wed, Jun 23, 2010 at 11:18 AM, Raj N rajn...@gmail.com wrote:

[algogeeks] Max(Xor (X([i],X[j]))

2010-06-23 Thread amit
Given a list of numbers , How to find the max(x[i] XOR x[j]) in the list. Any solution less than O(n^2)? -- 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

[algogeeks] Re: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers

2010-06-23 Thread Jagadish M
Why not just change the definition of when one number is bigger than another and do normal sort ? I guess that is better and simpler. Normal sort takes O(n log n), while Anurag's algo is O(n). Regards, Jagadish http://www.cse.iitb.ac.in/~jagadish On Jun 20, 2:18 pm, Rohit Saraf

[algogeeks] getting smallest 1 million numbers....

2010-06-23 Thread amit
Given a set of 1 Trillion integers on hard disk, find the smallest 1 million of them. You can fit at most 1 million integers in memory at a time. State the fastest solution you can think of. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] Where to Set the POST-OFFICE

2010-06-23 Thread amit
There are N points on a LINE. U neeed to place a post office such that its total distance from each of the N points is minimised. The post office need not necessarily be on one of the N Points. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] linked list

2010-06-23 Thread divya jain
if we dont want to change original list.. is there ny efficient method for that? On 23 June 2010 06:49, ANUJ KUMAR kumar.anuj...@gmail.com wrote: reverse one of the linked lists in O(n) time and then see if the resulting one is same as the other one On Wed, Jun 23, 2010 at 1:56 AM, divya

[algogeeks] Find the next number for a given number without using any arithmetic operators(use bit operations)

2010-06-23 Thread vijay
Find the next number for a given number without using any arithmetic operators(use bit operations) -- 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

Re: [algogeeks] linked list

2010-06-23 Thread Amit Mittal
this is same as finding palindrome in a given linked list.. it may help http://geeksforgeeks.org/?p=1072 On Wed, Jun 23, 2010 at 6:00 PM, divya jain sweetdivya@gmail.comwrote: if we dont want to change original list.. is there ny efficient method for that? On 23 June 2010 06:49, ANUJ

Re: [algogeeks] Re: no of bits

2010-06-23 Thread Anand
@Dave I tried your logic on 15 it got converted to 10, 4, 4,4. But still could not understand the logic could you please explain? On Tue, Jun 22, 2010 at 9:34 PM, Dave dave_and_da...@juno.com wrote: Did you actually try the code by hand on a number to see what it does? If you do, you will

[algogeeks] Re: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers

2010-06-23 Thread Dave
No, Jagadish. You missed the statement Now use any inplace sorting algorithm in Anurag's posting, which makes his algorithm also O(n log n), and both Anurag and you missed the statement should not do any pre or post processing. Dave On Jun 23, 8:52 am, Jagadish M jagadis...@gmail.com wrote: Why

[algogeeks] Re: check divisibility

2010-06-23 Thread Dave
In step 3, if n m, then n can be written in the form i * 2^k + j, where i 0 and 0 = j = m. Then, step 3 replaces n by i + j. Note that (i * 2^k + j) - (i + j) = i * (2^k - 1) = i * m. Therefore, the step replaces any number greater than m by a small number that differs from it by a multiple of