Any 3 points always form a triangle, unless they are collinear. So all
you need to do is to find if the slopes wrt the 3 planes is the same
for lines formed using any 2 points.
Regards,
Aakash
On 5/27/07, Feng <[EMAIL PROTECTED]> wrote:
>
> Hi all!
>
> Given 3 points in 3D, what is the fast and
There are many efficient ways to do this. I am listing them out.
1) Use two pointers. One advancing one node at a time and the other
advancing 2 nodes at a time. So that the relative speed between them is
always one node. If the first and second pointer coincide then there is a
loop.
2) Destructi
There is a highly optimal O(n) solution available.
1) Find the depth at which each node is situated let them be du and dv
respectively for u and v
2) Not bring u and v to the same depth. that is skip abs(du-dv) nodes from
the greater depth node
3) Compare both nodes and do a (u=u->parent and v=v->
Looks like the analysis sucked.
The answer is as follows:
Sort array (using merge sort) => n*log(n) complexity
for(i=0;a[i] n complexity
{
if(binary_search for value (x-a[i]) in the range i+1,n =>log(n) complexity
}
So sorting = n*log(n)
for loop and search = n*log(n)
Which gives overall comp
faster retrievals trie is the way to go.
If you want to overcome the overheads of a trie (mainly the space
utilization) try hashing the names or use a B Tree.
Regards,
Aakash
On 2/15/07, aakash mandhar <[EMAIL PROTECTED]> wrote:
>
> I would recommend using a trie, and a list of all num
I would recommend using a trie, and a list of all numbers for the same name
at a terminating point of the trie.
Regards,
Aakash
On 2/14/07, Karthik Singaram L <[EMAIL PROTECTED]> wrote:
>
> It does depend on the size of the problem you have in mind. Tries can be
> expensive for names depending on
/* You can do it as shown below. */
#include
#include
using namespace std;
int random(int low,int high)
{
srand(time(NULL));
int n=(high-low+1);
return low + (rand()%n);
}
int main()
{
cout< wrote:
>
>
> Question:
>
>
> Given a program which can generate one of {1, 2, 3, 4, 5} randomly.
>
for(int i=0;i<=n/2;i++)
{
for(int j=0;j<=i;j++)
{
a[i][j]=='*';
}
for(int j=i+1;j wrote:
>
>
> OK, I need to write an algorithm to populate a 2D array A(i,j) of size
> n x n. There is 1 '*' in the 1st row, increasing to n/2 in the middle
> row, this decreases back to 1'*' in the last row. We can a
/*
A compiling version of Atamurad's code
*/
#include
using namespace std;
int oddman(int a[], int n)
{
int res=0;
for(int i=0;i wrote:
> I am not sure how XOR will be defined on numbers.
Let X be number which occurs only once in sequence.
and i1, i2 are same, ie i1=i2. where i is one of
The XOR solution is the best.
The underlying asssumption is that the numbers are int and the bitwise
operators are fast on the machine (as on most machines).
Regards,
Aakash
On 1/16/07, Satish <[EMAIL PROTECTED]> wrote:
Hangjin Zhang wrote:
> Do an XOR on all numbers. The resulte is the numb
10 matches
Mail list logo