🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.theory
Article #2100

String prefix matching

#2100
From: douglas.e.whitten
Date: Sat, 24 Feb 1990 16:48
39 lines
1622 bytes
I am looking for an efficient algorithm for longest-prefix matching.

My application can be described as follows:
    INIT:
	1. Given a large number of variable-length binary strings.
		Call them "keys".
	2. Build a search data structure: For instance, a trie.
    RUN:
	1. Given a string.  Call it a "word".
	2. Search the data structure to find the longest "key" that is
		a prefix (aka initial substring) of "word".

The data structure, once built, is only searched: There is no add or
delete required.  I am currently planning to completely rebuild the
data structure when changes are necessary.

The "keys" and "words" are binary strings, with byte values from 0x00
to 0xff.  They range in length from one byte to 40 bytes.

It is possible for no "key" to be a prefix, as well as a "key" to
completely match a "word".

Note that I need the longest match: Some "keys" will themselves be
prefixes of other "keys".

My implementation language will be C.  

I am interested (first) in fast search time, (second) in reasonable
memory requirements, and (third) in fast data-structure construction
time.

Any suggestions?



		Doug Whitten
		AT&T Bell Labs
		dewo1@cbnewsd.ATT.COM
Technical Details
Message-ID: <13367@cbnewsd.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!pacbell!att!cbnewsd!dewo1

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!ames!pacbell!att!cbnewsd!dewo1
From: dewo1@cbnewsd.ATT.COM (douglas.e.whitten)
Newsgroups: comp.theory
Subject: String prefix matching
Keywords: string prefix
Message-ID: <13367@cbnewsd.ATT.COM>
Date: 24 Feb 90 16:48:57 GMT
Reply-To: dewo1@cbnewsd.ATT.COM (douglas.e.whitten,iw,)
Organization: AT&T Bell Laboratories
Lines: 39