Re: interview question on primes
- From: quasi <quasi@xxxxxxxx>
- Date: Mon, 25 Feb 2008 20:48:13 -0500
On Tue, 26 Feb 2008 12:28:27 +1100, "Peter Webb"
<webbfamily@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
"Digital Puer" <digital_puer@xxxxxxxxxxx> wrote in message
news:3bdc49e5-d202-491a-bde2-c7c31bee801f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Got this on a software engineering interview question:
given two integers A and B, find all primes between them.
I basically wrote an initial function, bool isPrime(int i), which
loops over all numbers between 2 and sqrt(i) to see if i%num == 0,
in which case the number is not a prime. With this function, I then
loop between A and B, calling isPrime() on each value.
Any better ideas?
The "correct" answer is heavily dependent on the range of values of A and B,
and if this is all the question states, its a pretty poor question.
No, not really.
It's a real world question, not an academic one.
Moreover, the question was not a "take-home project". Presumably it
was expected to solved right then and there, at the interview.
Judgement is required here.
Of course, the applicant can always _ask_ the interviewer about the
range of values, but in my opinion, having to ask that question would
show a lack of common sense. The very fact that the range was not
specified, together with the implied time constraints of the
interview, should be enough for the applicant to opt for a clean,
simple, standard solution.
quasi
.
- Follow-Ups:
- Re: interview question on primes
- From: 1787
- Re: interview question on primes
- From: Tim Little
- Re: interview question on primes
- References:
- interview question on primes
- From: Digital Puer
- Re: interview question on primes
- From: Peter Webb
- interview question on primes
- Prev by Date: "What is the purpose of life?"
- Next by Date: Re: "What is the purpose of life?"
- Previous by thread: Re: interview question on primes
- Next by thread: Re: interview question on primes
- Index(es):
Relevant Pages
|