Hi..
Think Ur Algo Will work only when u and v are at equal height frm
their Common ancestor 'P'
So U need to think of all possibilities
Node* ClosestCommonAncestor(Node* u, Node* v)
{
if(! u && v )
return NULL;
if( u == v)
return u->parent;
x = ClosestCommonAnce
. How to reverse all the bits in a unsigned integer? an signed
integer (you have to keep the sign of the integer)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send
For the following definition of a binary tree node
typedef struct _Node
{
_Node * Left;
_Node * Rigth;
_Node * Parent;
} Node;
Given 2 nodes u and v from a tree, find the closest common
ancestor
of u and v?
Node* ClosestCommonAnces
traverse the tree layer by layer.
void BF_Traverse(Node* r)
--~--~-~--~~~---~--~~
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
How to count the 1 bits in a integer?
int Count1Bits(int i);
How about this function is used very often?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send e
Using 4 binary bits you can represent 16 numbers, from to
. How can you print all these 16 numbers in binary format, i.e.
"",
"0001", "0010" You can choose whatever order to print.
Now give you n bits, how can you print out all the n bit numbers in
binary format?
Can you write a r