BlackBerry

  www.blackberry.com
  www.blackberry.com

Interview Question

Software Developer Co-Op Interview Waterloo, ON (Canada)

Write a function to sort N decks of 52 playing cards

  represented as an integer array with indexes from 0 to N*52 - 1. You are supplied a random generator that produces numbers from 0 to N - 1 for this task. What is the worst case runtime and memory bound?
Answer

Interview Answer

1 Answer

0

Iterate the array and on each iteration use the random number generator to select another cell in the array to swap your current value with. O(N) runtime, O(1) memory usage.

Interview Candidate on Oct 30, 2009

Add Answers or Comments

To comment on this, Sign In or Sign Up.