Xref: utzoo comp.lang.c:30965 comp.sources.wanted:12808 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!watson!ssdken From: ssdken@watson.Claremont.EDU (Ken Nelson) Newsgroups: comp.lang.c,comp.sources.wanted Subject: Re: Wanted -- ambiguous lookup routine. Message-ID: <8075@jarthur.Claremont.EDU> Date: 9 Aug 90 20:43:48 GMT References: <1990Aug9.082839.3663@ifi.uio.no> Sender: news@jarthur.Claremont.EDU Reply-To: ssdken@watson.Claremont.EDU (Ken Nelson) Followup-To: comp.lang.c Lines: 44 I would have responded by mail but your address kept bouncing. How about this approach: When you store your strings store them in some kind of fast access tree, B-tree, AVL, Splay, or perhaps a hashed structure. Save them with the string as the key, and with the initials as the key. example: /* bsearch is a unix function for inserting, or searching into a binary tree. You could replace this with any type of insert into a fast access structure. Don't really try this code it won't work, it is here to explain the concept. */ bsearch("John F. Kennedy",tree,"John F. Kennedy") bsearch("JFK",tree,"John F. Kennedy"); This is pretty fast, and space could be minmized by putting pointers to strings into the tree instead of having a copy of the string in each node of the tree. This approach works for state abbreviations as well, it is really like aliasing when writing parsers, and scanners.... Hope this helps, Ken Nelson Principal Engineer Software Systems Design 3627 Padua Av. Claremont, CA 91711 (714) 624-3402