onion834
BAN USERin first statement, we are declaring a function pointer p, which takes 2 arguments (an array 'a' of void pointers and an integer) and returns nothing.
in 2nd statement, we are declaring an array 'p' of function pointers, with 2 arguments ( a void pointer and an integer) and returns a void pointer.
Ratn,
The question was to find the common ancestor for two given values, is it ok to consider them as pointers?
I think we should replace your condition with (root->value == p || root->value == q). This will ensure that the values p and q are searched instead of pointers. And an ancestor close to the root will be found even if the values p and q are not children to the same parent and in different levels.
But, in this approach problems will creep in, if the values are not unique in the tree.
<quote> if(root->left==p||root->right==p||root->left==q||root->left==q) </quote>
Assuming the array is of size NxN and N is an odd number.
over = 0;
for(i=0;i<=N && !over;i++)
{
j=0;
for(j=0, player = arr[i][j]; player == a[i][j] ; j++) //check row
if(j==N) over = 1;
for(j=0, player = arr[j][i]; player == a[j][i] && !over ; j++) // check col
if(j==N) over = 1;
if(i==1 || i == (N+1)/2) //check diagonal and set if over
}
print "winner is " player;
T.C
- rndBit does not have equiprobability to produce 0 and 1. 1,3,5 will return 1 and 2,4 will return 0.
- do we need rndBit()<<3 here as it is ANDed with 6(0x110)?
- adding 1 and ANDing with 6 will always result in 0 in LSB. so it won't generate odd numbers.
This is print from LSB. We should print from MSB.
- onion834 January 21, 2009