the wallet works on the basic idea, that balance can be obtained instantenously suppose a wallet address sent and received funds in blocks 1000 and 2000 respectively. Even if the address is part of inumerable tx ( between 1001-1999) blocks, it's balance doesn't change and wallet can detect using maths that the balance has not changed using a binary search algorithm