[algogeeks] Re: find the closest common ancestor of node u and v?

2007-03-20 Thread Balachander
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

[algogeeks] reverse all the bits in a unsigned integer

2007-03-20 Thread hijkl
. 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

[algogeeks] find the closest common ancestor of node u and v?

2007-03-20 Thread hijkl
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

[algogeeks] traverse the tree layer by layer.

2007-03-20 Thread hijkl
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

[algogeeks] count the 1 bits in integer

2007-03-20 Thread hijkl
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

[algogeeks] print n bit numbers in binary format..

2007-03-20 Thread hijkl
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