Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
January 31st, 2012, 01:24 AM
 dhiman_nikhil
Registered User

Join Date: Jan 2012
Posts: 1
Time spent in forums: 10 m 14 sec
Reputation Power: 0
Need the best way/algorithm to use for following condition?

Hi all,
Lets take example first
I have a list of users having different values of A,B,C.
user A B C
User 1. test1 A1 B1 C3
User 2 test2 A1 B1 C1
User 3 test3 A2 B3 C3

A contains element in range of (1-400)
B contains element in range of (1-200)
C contains element in range of (1-300)

So i need to develop a algorithm that gives me the result in very quick time whenever i query for those variable A,B,C
ex. give me users whose A=A1, B=B1, C=C3 [Answer should be test1]
i can also say give me users whose A=A1[Answer should be test1,test2]

Thanks
Nikhil

#2
February 24th, 2012, 11:54 PM
 jwdonahue
Contributing User

Join Date: May 2004
Posts: 3,417
Time spent in forums: 3 Weeks 5 Days 12 h 51 m 9 sec
Reputation Power: 886
Build three lists of value and name-list pairs from the original data source. Then for each criteria in the query, find the union of the specified lists. So for A=2, you just look in the A list for value=2 and return the list of names (test3) and for A=1, B=1 take the union of the A=1 result and the B=1 result (test1,test2).
__________________
I no longer wish to be associated with this site.

 Viewing: Dev Shed Forums > Programming Languages - More > Software Design > Need the best way/algorithm to use for following condition?