I am reading and watching about transactions and they say a transaction's input is previous transaction's output. They all show diagrams in which these transactions are consecutive.
How an account's balance is found if the latest input and previous output are away from each other away more than 1 transaction.
Also how an account's balance is found if there are some outputs to that account with small values in different transactions and another output which is account's balance? How they are gathered?
With which algorithm wallets traverse blockchain?
I am making my own node and wallet to grasp bitcoin better and couldn't understand these things about transactions.