マガジンのカバー画像

Algorithm

5
運営しているクリエイター

#algorithm

Factorial with recursion

Ever wonder how recursion works in code? Imagine when you are given 6!, you first multiply the next integer factorial in sequence (6! = 6*5!). You repeat the process until 0 is reached. This works the same way in programming. Just think of

Stack

A stack is an abstract data type that allows operations to store and remove values in a collection of elements. All operations have a runtime complexity of O(1) because you can only delete or add an element in the top of the stack. Elements