Is it possible to have the same public and private key pair that got generated by the algorithm ? How is the algorithm generating public and private keys..
Theoreticaly, yes it is possible.
But practically, it is not possible because the chances are almost zero.
You could use the whole energy available on earth and wouldn't generate a private key which already has been generated. In fact you would have created < 1% of all possible private keys.
Private keys are not generated by any algorithm. A private key is just a 256 bit
random number.
The public key is then calculated through multiplication on the eliptic curve (in bitcoins case: secp256k1).
The address is then derived by calculating the hash:
RIPEMD-160(SHA256(public_key)).