Differences between algorithm and abstraction

I am assuming you have other functions like this for level 1 and 2. The function “ToenterLevel3” could be considered an algorithm. It is using logic (if - else statement) and some math (stats[4]++). It is also using other algorithms - “gamestats” and “tracklives”.

If you have other similar functions for level 1 and 2 (perhaps “ToenterLevel1” and “ToenterLevel2”) and are calling “gamestats” and “tracklives” in those functions, “gamestats” and “tracklives” can be treated as abstractions. You are calling them at multiple places. These abstractions are helping you handle the complexity of your code by reducing repetition of code in multiple places.

In conclusion, I would use the “ToenterLevel3” as an algorithm and one of the functions “gamestats” or “tracklives” as an abstraction.

1 Like