TopCoder Algorithm Tutorial
Google CodeJam
Algorithm tutorials are avaiable on The Link... Algorithm Link on Topcoder
Some of the Binary Tricks
n=(1011101110) base 2
for i->n , i>0 i=(i&(i-1))
print (i) in binary formate...
gause what this will print...
k.... if u have find out then ok...otherwise....just see the how the value of i will change....
i=1011101110
i=1011101100
i=1011101000
i=1011100000
i=1011000000
i=1010000000
i=1000000000
i=0000000000
//next trick...
you can change the value of the two varaible in bitwise
//eq swap a,b
a=a^b
b=a^b
a=a^b
this code look...somthing rediculous, but it will do the work....
//choosing subset problem using bitwise
u can use simple use this loop to get the subset of a n element set
for(int i=0;i (1<(1<<n); i++)
{
{
for(int j=0;j<n ; j++)
{
if(i&(1<<j))
cout << j
}
cout << endl;
}
you have a nice site. thanks for sharing this site. you can download lots of ebook from here
ReplyDeletehttp://feboook.blogspot.com
u have great blog site...very knowledgeable, educative and informative keep carry on............
ReplyDelete