Beginner’s Big O for Swift Developers
Get those algorithms right
Difficulty: Beginner* | Easy | Normal | Challenging
This article covers Big O notation from the theory to practical examples in the Swift language including constant, linear and polymorphic time examples (but don’t worry, the code is here too!)
*This is seen as a beginner topic (first year Computer Science degree fare) but is certainly not easy.
Prerequisites:
- Coding in Swift Playgrounds (guide HERE)
- You’ll need to know something about Arrays in Swift, Loops and if statements
Terminology
Algorithm: A process or set of rules to be followed
Big O Notation: A mathematical notation to describe the limiting behaviour of a function when an argument tends towards infinity
Space complexity: The quantification of the amount of memory taken by an algorithm to run, as a function of its input
Time complexity: The quantification of the amount of time taken by an algorithm to run, as a function of its input