July 2018
Intermediate to advanced
266 pages
7h 11m
English
Many algorithms are built around operations that need only the CPU to be completed. The performance of such algorithms will be delimited by the CPU in which they are running, and solely upgrading the CPU will usually improve their performance.
Let's think, for example, of a simple algorithm that takes a word and returns whether it's a palindrome or not:
fun isPalindrome(word: String) : Boolean { val lcWord = word.toLowerCase() return lcWord == lcWord.reversed()}
Now, let's consider that this function is called from another function, filterPalindromes(), which takes a list of words and returns the ones that are palindromes:
fun filterPalindromes(words: List<String>) : List<String> { return words.filter { isPalindrome(it) }}
Finally, ...
Read now
Unlock full access