How bitcoin finds a few transactions earlier account balance from outputs? 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.
How an account's balance is found if the latest input and previous output are away from each other away more than 1 transaction.


They never are. They are the same. Someone's input becomes someone else's output, until he decides to spent said output as an input in a new transaction. 

Or, am i not understanding the question? Are you asking why a wallet understands why an output ...(that he received more than X blocks away) still belongs to him? See =>


  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?


I don't really understand what you're asking here, but your node keeps track of every transaction, and then creates a UTXO set- Unspent Transaction Output.
In this set are all the unspent outputs of the entire network. The wallet then checks if any of these outputs belong to an adress you own (Note: the wallet doesn't actually directly use the adress to scan for UTXO's, but rather the output script, but for practicality you can just see it as an adress, i  guess.) (have the private key of), and if so - will show it as belonging to you - and thus your (account) balance.