CodingStatistics

Given a function roll() that uniformly returns a double between 0 and 1 and a array/list of numbers of length N (no duplicates), create a function shuffle() that returns a permutation of equal probability

Data Scientist

Meta

Udacity

Klarna

DigitalOcean

WeWork

Slack

Did you come across this question in an interview?

  • Given a function roll() that uniformly returns a double between 0 and 1 and a array/list of numbers of length N (no duplicates), create a function shuffle() that returns a permutation of equal probability
  • How would you design a shuffle() function that utilizes roll() to ensure uniform distribution across an array?
  • Can you create a shuffle function using a roll() function that guarantees an equal chance for each permutation?
  • What is your approach to writing a shuffle() function that leverages roll() for a nonduplicative number array?
  • How can you ensure that the shuffle() function you create will have equally probable permutations?
  • Could you demonstrate how the roll() function can be used to implement a fair shuffle() function?
  • How would you code a shuffle() function that randomizes an array uniformly using roll()?
  • Can you write a shuffle() function that uses roll() to produce a uniformly distributed permutation of a list?
  • Outline the development of a shuffle() function that employs roll() to ensure equal probability of permutations.
  • How do you envision a shuffle() algorithm that integrates a roll() function for equal distribution?
  • Given a function roll() that uniformly returns a double between 0 and 1 and an array/list of numbers of length N (no duplicates), create a function shuffle() that returns a permutation of equal probability

Interview question asked to Data Scientists interviewing at Transferwise, Deliveroo, Squarespace and others: Given a function roll() that uniformly returns a double between 0 and 1 and a array/list of numbers of length N (no duplicates), create a function shuffle() that returns a permutation of equal probability.