There is no one algorithm. The game is a combination of luck and skill. It also has factors such as the number of players in a hand, and where your seating position is relative to the dealer.
To deal the flop, the dealer burns the top card on the deck and puts it face down on the table, out of play. The top three cards on the remaining deck are then placed face up in the middle of the table. The players that advanced to the flop then commence another betting round.