Katkat

Pass functions and analyze basic data structures

eBaySoftware Engineer · Onsite

Last 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.