Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I explain what a "naive implementation" is? [closed]

What is the clearest explanation of what computer scientists mean by "the naive implementation"? I need a good clear example which will illustrate — ideally, even to non-technical people — that the naive implementation may technically be a functioning solution to the problem, but practically be utterly unusable.

like image 380
afeldspar Avatar asked Nov 02 '08 20:11

afeldspar


People also ask

What does naive implementation mean?

A naive implementation is an implementation that has taken shortcuts for the sake of simplicity or by lack of knowledge. It will not take account for all the possible uses cases or don't try to fit in every situation.

What does naive approach meaning?

A naive approach consists of calculating a histogram of angles, assuming the accumulation of points corresponding to the directions of interest will result in visible peaks.

What does naive solution mean?

Naive means just that what it says: A first, stupid solution to the problem, that solves it, but maybe not very time-/space efficient.


2 Answers

I'd try to keep it away from computers altogether. Ask your audience how they find an entry in a dictionary. (A normal dictionary of word definitions.)

The naive implementation is to start at the very beginning, and look at the first word. Oh, that's not the word we're looking for - look at the next one, etc. It's worth pointing out to the audience that they probably didn't even think of that way of doing things - we're smart enough to discount it immediately! It is, however, about the simplest way you could think of. (It might be interesting to ask them whether they can think of anything simpler, and check that they do really understand why it's simpler than the way we actually do it.)

The next implementation (and a pretty good one) is to start in the middle of the dictionary. Does the word we're looking for come before or after that? If it's before, turn to the page half way between the start and where we are now - otherwise, turn to the page half way between where we are now and the end, etc - binary chop.

The actual human implementation is to use our knowledge of letters to get very rapidly to "nearly the right place" - if we see "elephant" then we'll know it'll be "somewhere near the start" maybe about 1/5th of the way through. Once we've got to E (which we can do with very, very simple comparisons) we find EL etc.

like image 106
Jon Skeet Avatar answered Oct 08 '22 22:10

Jon Skeet


StackOverflow's Jeff Atwood had a great example of a naive algorithm related to shuffling an array.

like image 39
Gareth Avatar answered Oct 08 '22 21:10

Gareth