Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How does the web app http://20q.net work? Can I write a similar program, in a smaller scale, and if yes how?

share|improve this question
add comment

1 Answer 1

Sure, this is called an "expert system" and can be represented by a binary tree (in the case of yes/no questions only). Each non-leaf node in your tree is a question (e.g. Is it a mammal?). Each leaf is a final answer (e.g. Giraffe) with an implied question Is it a giraffe?. If the answer to this final question is yes, the user guessed the answer. If the answer is no, then the user should be prompted to input a new question (added to the database) where the answer is yes for the new answer (e.g. wombat) and no for the old answer (giraffe). The system grows in "intelligence" the more it is used.

share|improve this answer
    
Thanks.. will definitely attempt to write one of these programs. –  Samrat Man Singh Feb 9 '11 at 4:55
    
Ahh the good ol' 20 questions exercise. Reminds me of late nights in the computer lab. –  Mike Brown Feb 9 '11 at 5:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.