Solutions in ES6 to common interview questions for CS positions.
Cracking the Coding Interview Reddit List of CS Questions
Return the most frequent item in a given array.
Recursive and iterative approaches to generate the nth Fibonacci number.
| Algorithm | Big O |
|---|---|
| Recursive | O(2n) |
| Iterative | O(n) |
Iterative is significantly faster for the node engine. Function calls require state and preservation and restoration while iteration jumps around in one function.
Test results from Node V5.0.0
Compute n = 0 to 50
Recursive approach took 554220ms
Iterative approach took 2ms
Difference (Rec - Intr) = 554218ms