473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

the lowest number of comparisons in string matching

Hi,

I'm looking for the algorithm which does the lowest number of
comparison for the string matching problem (in the worst case).

I know that the complexity is liniar in the length of the strings, but
I'm interested in finding the actual number of comparisons.

The lowest number (theoretical) is m-n+1, but as far as I know no
algorithm has achived this limit.

(where m is the lenght of the text and n is the length of the pattern).

Thanks,
Laura

Sep 22 '06 #1
2 2696
laura wrote:
>
I'm looking for the algorithm which does the lowest number of
comparison for the string matching problem (in the worst case).

I know that the complexity is liniar in the length of the strings,
but I'm interested in finding the actual number of comparisons.

The lowest number (theoretical) is m-n+1, but as far as I know no
algorithm has achived this limit.

(where m is the lenght of the text and n is the length of the
pattern).
This is off-topic here. Try comp.programming. Cross posted and
followups set.

Search for Boyer-Moore and Knuth-Morris-Pratt algorithms.
Sedgewicks "Algorithms" covers it nicely. KMP is nice in that it
avoids backtracking and works with streams.

--
Some informative links:
news:news.announce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

--
Posted via a free Usenet account from http://www.teranews.com

Sep 22 '06 #2
In article <11**********************@e3g2000cwe.googlegroups. com>,
laura <la*************@gmail.comwrote:
>I'm looking for the algorithm which does the lowest number of
comparison for the string matching problem (in the worst case).
That's an algorithms question, not a C specific question, so you
are advised to check with a newsgroup that deals with algorithms.
>I know that the complexity is liniar in the length of the strings, but
I'm interested in finding the actual number of comparisons.
You haven't defined *which* "string matching problem" you are
dealing with. It is also rather odd that you are concentrating
on the worst case to the exclusion of the average case.

>The lowest number (theoretical) is m-n+1, but as far as I know no
algorithm has achived this limit.
That's not the theoretical limit when you take into account locale
problems and case sensitivity...
--
"law -- it's a commodity"
-- Andrew Ryan (The Globe and Mail, 2005/11/26)
Sep 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Randi | last post by:
I am having problems with this question: Write a C++ while statement that will input numbers from a file until the end of file is reached. Output the lowest number in the file. Ok, I do...
3
by: Andy Fish | last post by:
In my XSLT stylesheet, if I call <xsl:number level="any" count="sdfsjdfjsdfksndfn"/> where there are no preceeding nodes called "sdfsjdfjsdfksndfn" I would expect it to return 0. However, on...
10
by: javuchi | last post by:
I'm searching for a library which makes aproximative string matching, for example, searching in a dictionary the word "motorcycle", but returns similar strings like "motorcicle". Is there such a...
4
by: Kelly B | last post by:
This is a simple string matching code from K&R2 (modified to match a user entered string from a text file) I tried to code an alternative strindex function(commented below) but it does not work...
8
by: kumarboston | last post by:
Hi All, I have a string of around 500 characters(alphabets) and I have a 3 arrays storing the position "start, end and type" for that string. i am trying to do is to match these position to the...
5
by: Zamdrist | last post by:
Let's say I have a result set (records) containing numbers such as: 0 1 2 3 9 16 21 45
6
Rabbit
by: Rabbit | last post by:
INTRODUCTION The Levenshtein Distance algorithm is an algorithm used to calculate the minimum number of edits required to transform one string into another string using addition, deletion, and...
4
Rabbit
by: Rabbit | last post by:
INTRODUCTION An ngram is the subsequence of n units from a given sequence. These units can be words, characters, etc. For example, the 2-gram, or bigram, of the phrase "Hello World" is "He", "el",...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.