Electrum: "restoring" a wallet from a seed Suppose I set up a wallet with a deterministic seed passphrase. I then use it, moving bitcoins around, sending some change to change addresses. Electrum will apparently create more addresses when required; suppose it does so.

I later on 'restore' the wallet on a new Electrum install by entering the existing seed. How does Electrum know how many addresses to create? It may be the case that the original 8 addresses are now empty (0 BTC), and my btc are in addresses created later on. How does Electrum know how many deterministic addresses to create in order to see all of my existing btc?

One possible technique I can imagine: Electrum looks at the blockchain for the first addresses in the wallet. If it sees traffic to those addresses, it knows to keep trying more of the deterministic addresses until it sees no more traffic, at which point it stops generating addresses in your wallet.
Electrum uses a gap limit to stop looking for addresses in the deterministic wallet. The default gap limit is set to 20, so the client get all addresses until 20 unused addresses are found.

Change addresses have a gap limit of 3 and this is not modifiable by the user.