mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-25 06:12:11 +08:00
Documentation for f1eddf4d65
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.13.2"/>
|
||||
<meta name="generator" content="Doxygen 1.14.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: dynamic_programming/minimum_edit_distance.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
@@ -19,7 +19,6 @@
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
<script type="text/javascript" src="../../navtree.js"></script>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../cookie.js"></script>
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
@@ -60,26 +59,20 @@ window.MathJax = {
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.13.2 -->
|
||||
<!-- Generated by Doxygen 1.14.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() { codefold.init(1); });
|
||||
/* @license-end */
|
||||
$(function() { codefold.init(); });
|
||||
</script>
|
||||
<script type="text/javascript" src="../../menudata.js"></script>
|
||||
<script type="text/javascript" src="../../menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('../../',true,false,'search.php','Search',true);
|
||||
$(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
@@ -94,10 +87,9 @@ $(function() {
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('da/d52/minimum__edit__distance_8cpp.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
$(function(){initNavTree('da/d52/minimum__edit__distance_8cpp.html','../../',''); });
|
||||
</script>
|
||||
<div id="container">
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
@@ -121,9 +113,6 @@ $(function(){initNavTree('da/d52/minimum__edit__distance_8cpp.html','../../'); i
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="summary">
|
||||
<a href="#namespaces">Namespaces</a> |
|
||||
<a href="#func-members">Functions</a> </div>
|
||||
<div class="headertitle"><div class="title">minimum_edit_distance.cpp File Reference</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
@@ -137,39 +126,33 @@ $(function(){initNavTree('da/d52/minimum__edit__distance_8cpp.html','../../'); i
|
||||
</div><div class="textblock"><div class="dynheader">
|
||||
Include dependency graph for minimum_edit_distance.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../de/d3d/minimum__edit__distance_8cpp__incl.svg" width="336" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
<div class="center"><iframe scrolling="no" loading="lazy" frameborder="0" src="../../de/d3d/minimum__edit__distance_8cpp__incl.svg" width="336" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div>
|
||||
<p><a href="../../da/d52/minimum__edit__distance_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
<tr class="heading"><td colspan="2"><h2 id="header-namespaces" class="groupheader"><a id="namespaces" name="namespaces"></a>
|
||||
Namespaces</h2></td></tr>
|
||||
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
|
||||
<tr class="memitem:dynamic_5Fprogramming" id="r_dynamic_5Fprogramming"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></td></tr>
|
||||
<tr class="memdesc:dd/d24/namespacedynamic__programming"><td class="mdescLeft"> </td><td class="mdescRight">Dynamic Programming algorithms. <br /></td></tr>
|
||||
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d12/namespace_minimum.html">Minimum</a></td></tr>
|
||||
<tr class="memitem:Minimum" id="r_Minimum"><td class="memItemLeft" align="right" valign="top">namespace  </td><td class="memItemRight" valign="bottom"><a class="el" href="../../d4/d12/namespace_minimum.html">Minimum</a></td></tr>
|
||||
<tr class="memdesc:d4/d12/namespace_minimum"><td class="mdescLeft"> </td><td class="mdescRight">Implementation of <a href="https://en.wikipedia.org/wiki/Edit_distance" target="_blank">Minimum Edit Distance</a> algorithm. <br /></td></tr>
|
||||
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table><table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:a0138c226bd79ffe6d839c787cfc60347" id="r_a0138c226bd79ffe6d839c787cfc60347"><td class="memItemLeft" align="right" valign="top">uint64_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0138c226bd79ffe6d839c787cfc60347">dynamic_programming::minimum_edit_distance::min</a> (uint64_t x, uint64_t y, uint64_t z)</td></tr>
|
||||
<tr class="memdesc:a0138c226bd79ffe6d839c787cfc60347"><td class="mdescLeft"> </td><td class="mdescRight">Takes input of the cost of three operations: Insert, Replace and Delete and return the minimum cost among them. <br /></td></tr>
|
||||
<tr class="separator:a0138c226bd79ffe6d839c787cfc60347"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ade2fcfe0359f3c7691bfaa04b14943e2" id="r_ade2fcfe0359f3c7691bfaa04b14943e2"><td class="memItemLeft" align="right" valign="top">uint64_t </td><td class="memItemRight" valign="bottom"><a class="el" href="#ade2fcfe0359f3c7691bfaa04b14943e2">dynamic_programming::minimum_edit_distance::editDistDP</a> (std::string str1, std::string str2, uint64_t m, uint64_t n)</td></tr>
|
||||
<tr class="memdesc:ade2fcfe0359f3c7691bfaa04b14943e2"><td class="mdescLeft"> </td><td class="mdescRight">Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute the minimum cost of a particular operation if it is already computed and stored in the <code>dp</code> vector. <br /></td></tr>
|
||||
<tr class="separator:ade2fcfe0359f3c7691bfaa04b14943e2"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memdesc:ade2fcfe0359f3c7691bfaa04b14943e2"><td class="mdescLeft"> </td><td class="mdescRight">Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute the minimum cost of a particular operation if it is already computed and stored in the <span class="tt">dp</span> vector. <br /></td></tr>
|
||||
<tr class="memitem:aa8dca7b867074164d5f45b0f3851269d" id="r_aa8dca7b867074164d5f45b0f3851269d"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="#aa8dca7b867074164d5f45b0f3851269d">test</a> ()</td></tr>
|
||||
<tr class="memdesc:aa8dca7b867074164d5f45b0f3851269d"><td class="mdescLeft"> </td><td class="mdescRight">Self-test implementations. <br /></td></tr>
|
||||
<tr class="separator:aa8dca7b867074164d5f45b0f3851269d"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a0ddf1224851353fc92bfbff6f499fa97" id="r_a0ddf1224851353fc92bfbff6f499fa97"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="#a0ddf1224851353fc92bfbff6f499fa97">main</a> (int argc, char *argv[])</td></tr>
|
||||
<tr class="memdesc:a0ddf1224851353fc92bfbff6f499fa97"><td class="mdescLeft"> </td><td class="mdescRight">main function <br /></td></tr>
|
||||
<tr class="separator:a0ddf1224851353fc92bfbff6f499fa97"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Implementation of <a href="https://en.wikipedia.org/wiki/Edit_distance" target="_blank">Minimum Edit Distance</a> using Dynamic Programing. </p>
|
||||
<p>Given two strings str1 & str2 and we have to calculate the minimum number of operations (Insert, Remove, Replace) required to convert str1 to str2.</p>
|
||||
<h3><a class="anchor" id="autotoc_md73"></a>
|
||||
<h3 class="doxsection"><a class="anchor" id="autotoc_md73"></a>
|
||||
Algorithm</h3>
|
||||
<p>We will solve this problem using Naive recursion. But as we are approaching with a DP solution. So, we will take a DP array to store the solution of all sub-problems so that we don't have to perform recursion again and again. Now to solve the problem, We can traverse all characters from either right side of the strings or left side. Suppose we will do it from the right side. So, there are two possibilities for every pair of characters being traversed.</p><ol type="1">
|
||||
<li>If the last characters of two strings are the same, Ignore the characters and get the count for the remaining string. So, we get the solution for lengths m-1 and n-1 in a DP array.</li>
|
||||
@@ -178,7 +161,7 @@ Algorithm</h3>
|
||||
<dl class="section author"><dt>Author</dt><dd><a href="../../github.com/nirzak" target="_blank">Nirjas Jakilim</a> </dd></dl>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html">minimum_edit_distance.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
</div><a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
|
||||
<a id="ade2fcfe0359f3c7691bfaa04b14943e2" name="ade2fcfe0359f3c7691bfaa04b14943e2"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ade2fcfe0359f3c7691bfaa04b14943e2">◆ </a></span>editDistDP()</h2>
|
||||
|
||||
@@ -208,7 +191,7 @@ Algorithm</h3>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute the minimum cost of a particular operation if it is already computed and stored in the <code>dp</code> vector. </p>
|
||||
<p>Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute the minimum cost of a particular operation if it is already computed and stored in the <span class="tt">dp</span> vector. </p>
|
||||
<dl class="params"><dt>Parameters</dt><dd>
|
||||
<table class="params">
|
||||
<tr><td class="paramname">dp</td><td>vector to store the computed minimum costs </td></tr>
|
||||
@@ -339,11 +322,11 @@ Algorithm</h3>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>x if <code>x</code> is the minimum value </dd>
|
||||
<dl class="section return"><dt>Returns</dt><dd>x if <span class="tt">x</span> is the minimum value </dd>
|
||||
<dd>
|
||||
y if <code>y</code> is the minimum value </dd>
|
||||
y if <span class="tt">y</span> is the minimum value </dd>
|
||||
<dd>
|
||||
z if <code>z</code> is the minimum value </dd></dl>
|
||||
z if <span class="tt">z</span> is the minimum value </dd></dl>
|
||||
<p>returns x, if x is the minimum value</p>
|
||||
<p>returns y, if y is the minimum value</p>
|
||||
<p>returns z if z is the minimum value</p>
|
||||
@@ -372,7 +355,7 @@ z if <code>z</code> is the minimum value </dd></dl>
|
||||
<td class="mlabels-left">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname">static void test </td>
|
||||
<td class="memname">void test </td>
|
||||
<td>(</td>
|
||||
<td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
|
||||
<td></td>
|
||||
@@ -419,11 +402,19 @@ z if <code>z</code> is the minimum value </dd></dl>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<div id="page-nav" class="page-nav-panel">
|
||||
<div id="page-nav-resize-handle"></div>
|
||||
<div id="page-nav-tree">
|
||||
<div id="page-nav-contents">
|
||||
</div><!-- page-nav-contents -->
|
||||
</div><!-- page-nav-tree -->
|
||||
</div><!-- page-nav -->
|
||||
</div><!-- container -->
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a class="el" href="../../da/d52/minimum__edit__distance_8cpp.html">minimum_edit_distance.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
|
||||
<li class="navelem"><a href="../../dir_8a20dd5bfd5341a725342bf72b6b686f.html">dynamic_programming</a></li><li class="navelem"><a href="../../da/d52/minimum__edit__distance_8cpp.html">minimum_edit_distance.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user