These days,in the solution section of many algorithmic challenges,I see this particular phrase 1<<j
,which is sometimes given as an exit condition for a for-loop,
what is the significance of these i<(1<<n)
and 1<<j
?
For example :
for(i=0;i<**(1<<n)**;i++)
{
sum=0;
for(j=0;j<n;j++)
{
if(i&**(1<<j)**)
{
sum+=a[j];
}
}
if(sum==m)
{
flag=1;
break;
}
}
edit:by "what is 1<<j
",I meant to what extent does the loop go?