There is no bitcoin protocol for how to determine balances. That decision is left up to the individual implementation of the wallet. Therefore, there could be various different implementations of various efficiencies depending on what wallet software you are using.
Generally however...
Wallets typically wouldn't "scan addresses". Instead they scan unspent outputs (the UTXO). For each unspent output, the wallet determines if it knows how to spend that output. If it does, then it adds the value of that unspent output to the balance that it displays to the user and continues scanning. If it does not, then it skips the output and continues scanning. Once the wallet has scanned all unspent outputs, it the total balance shown will be the balance that the wallet believes it knows how to spend.