Pass functions and analyze basic data structures
eBaySoftware Engineer · OnsiteLast updated
This question evaluates proficiency with higher-order functions, passing functions or delegates, closures, and reasoning about side effects, alongside the ability to analyze fundamental data structures and their performance characteristics.
Implement a function applyTwice(f, x) that accepts a function f and a value x and returns f(f(x)) in your preferred language. Demonstrate how to pass functions (or delegates) as parameters and discuss closures and side effects. Then analyze arrays, linked lists, stacks, and queues: give time/space complexities for insert, delete, search, and iteration, and explain when you would choose each structure.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.