The ip address can be divided into 3 parts --netid + subnetid+hostid
--no of bits n of netid can be predicted according to the class used in addressing in classful notation and it will be given in \n formate in classless notation.
--Remaining 32-n bit is used for subnetting and Hostid.
---if no of subnetts is 2m and size of each sunet is k then
-----to recognise each subnet,we should have unique id for each subnet.since there is 2m subnet so, m bit will be needed for subnetting and rest will be used for hostid.
NOTE- we should use the leftmost bit of (32-n) bit for subnetting which will ensure serial addresses to be serial but it is not always necessary bt practically this is the only way