In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use BF algorithm to achieve string matching in Java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Concept
Single-pattern string matching is the matching of one string a with another string B. generally speaking, the length of an is much longer than b, and we look in a to see if b is included. We call the string a the main string and the string b the pattern string.
BF algorithm
BF algorithm has become a violent matching algorithm, also known as naive matching algorithm. It's also the simplest algorithm that we often use. The simplest method is to compare m characters at a time, and compare n-m+1 times in the worst case. The worst-case time complexity of BF algorithm is O (nymph).
Steps
1 the mode string is compared with the main string character one by one. If it is the same, then the main string is different, then the main string moves one bit, and then the pattern string is compared from scratch.
Package com.github.strings;public class bf {public static int search (String str,String pat) {int sLen = str.length (); / / main string int pLen = pat.length (); / / pattern string length / / number of times to match for (int itemositi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.