hello, i came across some c++ codes using following statements :
now i dont understand what 1<<n means...i have never used << operator like this before and was not able to find anything about it on the net
It is bitwise shift operator. It shifs the value of the left operand the number of times specified by the right operand.
1 << n <=> 2^n, where ^ means power of.
Since at least 20 years modern compilers will internally translate 2^n to this bitshift if supported by the CPU (nearly every CPU does support it).
int dp[1<<21]; is interesting because it addresses a really big array with at least sizeof(int) * (1 + 2^21) bytes.
thankyou all...it helped a lot
@cire: Ok, you're right with the meaning of ^ in C++. But I've defined it to the power of. So in this context its quite right the power of. Your other statements I agree with you.