BlackBerry

  www.blackberry.com
Work in HR? Unlock Free Profile

BlackBerry Software Developer Co-Op Interview Question

I interviewed in Waterloo, ON (Canada) and was asked:
"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?"
Add Tags [?]
Answer

Part of a Software Developer Co-Op Interview Review - one of 383 BlackBerry Interview Reviews

Answers & Comments

0
of 0
votes
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

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.