Pergunta de entrevista da empresa National Instruments

Design a deck class. Given a fully implemented deck class, design a shuffling algorithm. Find the arithmetic mean of a binary tree. Follow-up to mean question: why can't you just design a function that recursively calculates the mean as it recurses the tree?

Resposta da entrevista

Sigiloso

18 de nov. de 2015

Deck -> began implementing, once it was clear I knew what I was doing they said okay good and moved on. Shuffling -> gave them Fisher-Yates shuffle. Arithmetic mean -> gave them an n(t) function and a sum(t) function and returned sum(t)/n(t). They asked me to redo it without traversing the tree twice, so I made a Tuple class and did n(t) and sum(t) at the same time.

1