Algorithm complexity
The efficiency of an algorithm is judged by its computational complexity, which mostly has to do with the number of times the algorithm needs to access its input data to do its job. The big O notation is used in computer science for describing the complexity of an algorithm. Thus, an O(n) algorithm, which needs to access its input only once, is considered better than an O(n2) algorithm, which is better than an O(n3) algorithm, and so on. The worst algorithms, however, are the ones with an O(n!) running time, which makes them almost unusable for inputs with more than 300 elements.
Lastly, most Go lookup operations in built-in types, such as finding the value of a map key or accessing an array element, have a constant time, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access