[算法]简单的字符串近似匹配算法实现

73、字符串匹配与近似字符串匹配算法详解 本文详细介绍了字符串匹配与近似字符串匹配的核心算法及其应用场景。内容涵盖从简单的O(mn)算法到KMP、Boyer-Moore、Aho-Corasick等高效精确匹配算法,并深入探讨了基于动态规划的编辑距离计算、Hirschberg算法、仿射间隙惩罚及Soundex发音匹配等近似匹配技术。文章还分析了各类算法的时间与空间复杂度,提供了实际应用案例和选择算法的决策流程图,推荐了Strmat、GNU grep、agrep等实用工具,帮助读者根据文本长度、查询频率、容错需求等因素选择最合适的方法。 阅读详情

 

GCC实现:

 

 

 

Visual Studio C++实现:

 

 

 

 

近似串匹配问题 动态规划法——C++代码 课程的随堂作业,C语言的,用dev就能运行,萌新代码,勿喷,仅仅帮助不想写作业的朋友方便一下,反正老师也不会仔细检查的 立即下载

相关推荐

近似串匹配的动态规划算法

经典 精典 精点 啊 算法太巧妙啦 介绍给大家看看 (C语言源程序),希望大家下载给我加点分啦。

字符串的近似匹配算法_近似字符串匹配指南

字符串的近似匹配算法Okay. So what exactly is the problem here? 好的。 那到底是什么问题呢? How often have we come across situations where we need to know if two strings are 'similar' but not necessaril...

cunchi8090的博客 4955

深入Android构建系统:一次修改ro.vendor.build.fingerprint失败的排查与解决记录

本文深入探讨了Android构建系统中修改ro.vendor.build.fingerprint的完整解决方案。通过分析vendor分区的特殊地位和构建指纹的生成路径,提供了三种实战修改方法,并揭示了指纹修改可能遇到的陷阱与对策,帮助开发者彻底解决这一常见问题。

weixin_30621711的博客 153

算法:字符串匹配、BF/KMP/近似匹配

#include #include using namespace std; #define MAXSTR 100 //----------------BF---------------- 时间o(n*m) int StringMatch_BF(char *str, char *pat) //O(M*N) M=|str| , N=|pat| { if(str==NU

997

WSOLA原理及matlab仿真

WSOLA原理 对于 OLA 算法来说,常常无法保持原信号中的周期性结构,在帧裁剪的过程中,不能保证每一个帧都能覆盖完整周期并保证其相位对齐,会产生相位跳跃失真。 为保证**基频不变**,就要使用 WSOLA 算法。 WSOLA 并不直接在 Ha 处找一帧进行直接拼接,而是在一个区间内寻找与理想帧最接近的一帧进行叠加。 ![在这里插入图片描述](https://img-blog.csdnimg.cn/8a234f4fde104fc69a9f3ddb7bcf3014.png?x-oss-process=ima

ManiacLook的博客 3223

NDVI空间分布变化Slope趋势分析与F检验(自用)

1.NDVI数据预处理2.一元线性回归分析3.Slope趋势分析与F检验

什么都学亿点点的博客 9021

【算法】近似串匹配问题(动态规划)

#include<iostream> using namespace std; int D[20][20]; // 填表矩阵设置为全局变量 int min(int a,int b,int c) { if(a<b && a<c) return a; else if(b<a && b<c) return b; e...

C_xixixixi的博客 4298

电工电子实验——3BIT延时电路的设计与实现

设计一个 3BIT延时电路。 设计分析: Ⅰ.根据触发器的特性,只有来两个触发脉冲时才能恢复到原来的状态。也就是说触发器的输出信号比触发信号延迟了一个触发脉冲周期即1bit。据此3bit就需要3个触发器。 Ⅱ.输出要可控就要加一控制器,可用选择器实现。 Ⅲ.为便于观察输出信号的延迟,可设计一个F1信号。

qq_55543315的博客 1129

近似串匹配问题(动态规划)

近似串匹配

失眠的树的博客 2374

再不入坑就晚了,深度神经网络概念大整理,最简单的神经网络是什么样子?

再不入坑就晚了,深度神经网络概念大整理,最简单的神经网络是什么样子?

我是香菜 3万+

ZYNQ系列PS侧和PL侧DDR3或DDR4在AD(Altium Designer 25)中的layout布线规则约束

DDR3或DDR4的PCB布线规则通常有相对固定的要求,对应的,在PCB设计时有固定的约束设置。

FPGA艺术家的博客 798

算法-动态规划法

动态规划是在20世纪50年代由美国数学家贝尔曼为研究最优控制问题而提出的,当该方法在应用数学中的价值被大家认同以后,在计算机学界,动态规划法成为一种通用的算法设计技术用来求解多阶段决策最优化问题。 所以,同学们,大家觉得特别难的动态规划问题是人家1950年想出来的,据目前已经有70年了。另外,有些同学也不要问计算机能不能改变世界了好吗?写CRUD确实挺难改变世界的,但是如果能想出如动态规划、Paxos、Raft等,或者能将数学上已经有的内容转化为计算机,都是很有贡献的!!! 动态规划法是将待求解问题分解成若

3602

华为OD机试真题 新系统【优化充电桩调度算法】

华为OD机试 新系统真题【优化充电桩调度算法】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【优化充电桩调度算法】

qq_45776114的博客 765

C#实现字符串模糊匹配

在C#中实现字符串的模糊匹配可以借助正则表达式或者一些模糊匹配算法来实现。

sunyao1314的博客 1999

OsgEarth开发笔记(三):Osg3.6.3+OsgEarth3.1+vs2019x64开发环境搭建(下)

上一篇编译了proj6.2.0、gdal3.2.1,本篇继续。 OsgEarth的编译,是基于Osg和OsgEarth结合在一起的,先要编译Osg,然后编译OsgEarth。OsgEarth的依赖库较多,分为上、中、下三篇,然后单独有一篇如何将编译好的osgEarth集成到Qt中。

长沙红胖子 Qt・西安|省级科研团队从业背景,深耕双一流体系高精尖技术配套研发|剥离高精尖机理,沉淀高端特种行业领域 Qt 工程化落地经验|博文仅分享通用技术总结,输出公开普适工程思路。 4万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

java谐音_谐 音 梗 生 成 器

笔者公众号:技术杂学铺duck不必,babe无耻……如何批量制造李诞的快乐源泉。(封面灵感来自奇葩说)阅读全文预计约9分钟段子:★★知识:★★★阅读本文你将学到:字符串相似度谐音梗,即通过谐音来制造笑点,比如book思议,Tony带水,贪生pass等等。谐音梗相较于其他段子来说比较容易创作,不用花费太多心思就能创作出令人愉悦的段子。当然,在李诞同学面前讲谐音梗会获得双倍的愉悦。谐音梗——李诞的快乐...

weixin_35810956的博客 3143

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

字符串近似匹配算法

zzy5177的专栏 1110

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

简单的字符串近似匹配

原理有空再写,其实就是动态规划 #include #include #include #include #define MAX  0XFFFFFFF using namespace std;   int min(int a,int b,int c) {     int t=a>b?b:a;  t=t>c?c:t;  return t;    } int find(

rudy45的专栏 1082

字符串匹配算法KMP原理详解及C++实现

问题介绍 KMP算法是用来解决字符串匹配算法的。例如给定一个主串T,判断其中是否出现了模式串P,即P是否为T的子串。例如:主串T为“hello”,模式串P为“el”,那么P就是T的子串;若模式串P为“elo”,那么P就不是T的子串。 暴力法解决字符串匹配 思路很简单。从主串的首字符开始匹配,如果匹配失败,则从主串的第2个字符开始匹配,以此类推。由于思路简单,直接上代码。 ...

bqw的博客 4485

[代码实例]字符串近似匹配算法 C++

[代码实例]字符串近似匹配算法英雄C、C++ (2003-10-29 13:00:21)  字符串的近似匹配,就是允许在匹配时有一定的误差,比如在字串“以前高手好久不见”中找“以前是高手”也能成功。具体地说,错误可以有三种类型:加字符(以前也是高手)、漏字符(以前高手)和替换字符(以前石膏手)。下面的函数在text中查找子串pat,最多允许有k个错误。返回的是匹配的终点(我还没

~~Jason 程序人生~~ 4710

字符串匹配算法

字符串的模式匹配 字符串的模式匹配是一种常用的运算。所谓模式匹配,可以简单地理解为在目标(字符串)中寻找一个给定的模式(也是字符串),返回目标和模式匹配的第一个子串的首字符位置。通常目标串比较大,而模式串则比较短小。 比如,原字符串为“ABCDEFG”,子串为“DEF”,则算法返回3。 模式匹配的类型 (1)精确匹配 如果在目标T中至少一处存在模式P,则称匹配成功,否则即使目标与模式只有一个字符不同也不能称为匹配成功,即匹配失败。给定一个字符或符号组成的字符串目标对象T和一个字符串模式P,模式匹配的目

朱萌的博客 946

近似模式匹配-查询匹配问题

一、搜索一个模式在文本中的所有近似出现输入:模式p=p1p2..pn,文本t=t1t2...tm以及参数(它是最大错配数)。输出:所有位置1titi+1....ti+n-1与p1p2...pn至多有k个错配(即:dH(ti,p)二、查询匹配问题找到所有与文本近似匹配的查询的子字符串输入:查询序列q=q1...qp,文本t=t1...tm,以及整数n和k输出:所有配对位置

深未来技术 1408

什么是字符串匹配算法?常见的字符串匹配算法有哪些?

字符串匹配算法是用于在一个文本字符串中查找特定模式字符串的算法。这些算法在计算机科学中具有广泛的应用,包括文本搜索、信息检索、数据处理、编译器和字符串处理等领域。其基本问题可以形式化为:给定一个文本字符串 TT 和一个模式字符串 PP,要找到 PP 在 TT 中的所有匹配位置或找到第一个匹配位置。:这是最简单的字符串匹配算法,通过逐个字符比较来查找模式串在文本中的位置。时间复杂度为 O(mn)O(mn),其中 mm 是模式串长度,nn 是文本串长度。

破损的天堂鸟博客 1070
上一篇: [经验总结]VC++内存泄漏定位与调试
下一篇: [经验总结] MFC DLL——Regular DLL and Extension DLL(转载)
ThinkHY
博客等级 码龄19年 168粉丝 247原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值