[algogeeks] Re: reverse all the bits in a unsigned integer

2007-03-22 Thread [EMAIL PROTECTED]
On Mar 21, 7:40 am, hijkl [EMAIL PROTECTED] wrote: . How to reverse all the bits in a unsigned integer? an signed integer (you have to keep the sign of the integer)? For an unsigned int, the following algorithm can be used (I believe you can find in in the Hacker's Delight book by H.Warren)

[algogeeks] A hanoi based problem

2007-03-22 Thread Mahdi
hello! It's a problem with all specifications of hanoi( 3 towers and and ordered rings) except that rings are not all in the same tower. They are distributed in 3 towers ( in each tower they are ordered ) and we want to bring them all in tower C ( assuming towers A,B,C). We want the solution with

[algogeeks] Re: count the 1 bits in integer

2007-03-22 Thread vim
how abt my code #includestdio.h int count1bitsn(int n) { int count=0; while(n) { count+=n1; n=n1; } } int main() { int n; printf(Enter the value of n\n); scanf(%d,n);

[algogeeks] Re: count the 1 bits in integer

2007-03-22 Thread vim
how abt my code #includestdio.h int count1bitsn(int n) { int count=0; while(n) { count+=n1; n=n1; } return count; } int main() { int n; printf(Enter the value of n\n); scanf(%d,n);

[algogeeks] Re: 2D arrays

2007-03-22 Thread Luciano Pinheiro
char a [n][n]; int i, j, m; m = n/2; if ( n % 2 == 0) m--; for(i = 0; i = m; i++) { for(j = 0; j = i; j++) { a[i][j] = '*'; a[n - i - 1][j] = '*'; } for(j = i + 1; j n; j++) { a[i][j] = '-'; a[n - i - 1][j] = '-'; } } 2007/3/18, BiGYaN [EMAIL PROTECTED]:

[algogeeks] Re: traverse the tree layer by layer.

2007-03-22 Thread tuesday
u can use a queen in bfs traverse void visit(Node* r) { } void BF_Traverse(Node* r) { queenNode* q; q.push(r); while(!q.empty()) { Node* t = *q.front(); q.pop(); visit(t); if(t-left !=0) q.push(t-left); if(t-right!=0)