I am studying the bitcoin internals and especially the proof-of-work. The proof-of-work is based on the mathematical problem that we have to compute from an input that produces a hash with a certain leading substring, I think the substring should start with a certain amount of zeroes.
We hash the current input with SHA-256 so we need to compute 2^256. Now my question is, we hash the previous block chain's hash with transactions and the nonce? Is it anything else including in the hash? Furthermore, if the first try is not successful the nonce is changed as a result to compute a new hash?
A few more questions: a) If we start adding transactions to a block and another block is created before our block, what happens to our work? We start mining from the beginning or we continue mining with our remaining transactions? b) Moreover, can we include blocks with 0 transactions to the block chain?