Senegal already has 4 points, so if they beat Algeria will be on 7 points. That leaves Algeria on 3 points. Under those circumstances, and if Bafana beat Ghana, then Bafana go second in the group and advance.
However, a draw between Algeria and Senegal would mean Senegal finish with 5 points, Algeria 4 points, and because of the head-to-head rule Bafana would not qualify.
If Algeria beat Senegal, Bafana still have to score three clear goals LESS whatever goals Algeria score against Senegal, to finish second.