mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-12 11:37:18 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: dynamic_programming/minimum_edit_distance.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: dynamic_programming/minimum_edit_distance.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -122,7 +139,9 @@ 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>
|
||||
</div><table class="memberdecls">
|
||||
</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>
|
||||
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>
|
||||
@@ -137,7 +156,7 @@ 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> (<a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str1, <a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str2, uint64_t m, uint64_t n)</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="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>
|
||||
@@ -157,6 +176,8 @@ Algorithm</h3>
|
||||
<li>Else, (If last characters are not the same), we will consider all three operations (Insert, Remove, Replace) on the last character of the first string and compute the minimum cost for all three operations and take the minimum of three values in the DP array. For Insert: Recur for m and n-1 For Remove: Recur for for m-1 and n For Replace: Recur for for m-1 and n-1</li>
|
||||
</ol>
|
||||
<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>
|
||||
<a id="ade2fcfe0359f3c7691bfaa04b14943e2" name="ade2fcfe0359f3c7691bfaa04b14943e2"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ade2fcfe0359f3c7691bfaa04b14943e2">◆ </a></span>editDistDP()</h2>
|
||||
@@ -167,12 +188,12 @@ Algorithm</h3>
|
||||
<tr>
|
||||
<td class="memname">uint64_t dynamic_programming::minimum_edit_distance::editDistDP </td>
|
||||
<td>(</td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></td> <td class="paramname"><span class="paramname"><em>str1</em></span>, </td>
|
||||
<td class="paramtype">std::string</td> <td class="paramname"><span class="paramname"><em>str1</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
<td></td>
|
||||
<td class="paramtype"><a class="elRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></td> <td class="paramname"><span class="paramname"><em>str2</em></span>, </td>
|
||||
<td class="paramtype">std::string</td> <td class="paramname"><span class="paramname"><em>str2</em></span>, </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="paramkey"></td>
|
||||
@@ -209,51 +230,40 @@ Algorithm</h3>
|
||||
<p>If last characters are same, ignore last char and recur for remaining string</p>
|
||||
<p>If the last character is different, consider all possibilities and find the minimum</p>
|
||||
<p>returning the minimum cost of operations needed to convert str1 to str2</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 93</span> {<span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 94</span><span class="comment"> /// Create a table to store results of subproblems</span></div>
|
||||
<div class="line"><span class="lineno"> 95</span><span class="comment"></span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<std::vector<uint64_t></a>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00092">92</a> of file <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html">minimum_edit_distance.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 93</span> {</div>
|
||||
<div class="line"><span class="lineno"> 95</span> std::vector<std::vector<uint64_t>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
<div class="line"><span class="lineno"> 96</span> m + 1,</div>
|
||||
<div class="line"><span class="lineno"> 97</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<uint64_t></a>(</div>
|
||||
<div class="line"><span class="lineno"> 97</span> std::vector<uint64_t>(</div>
|
||||
<div class="line"><span class="lineno"> 98</span> n +</div>
|
||||
<div class="line"><span class="lineno"> 99</span> 1)); <span class="comment">/// creasting 2D vector dp to store the results of subproblems</span></div>
|
||||
<div class="line"><span class="lineno"> 100</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 101</span><span class="comment"> /// Fill d[][] in bottom up manner</span></div>
|
||||
<div class="line"><span class="lineno"> 102</span><span class="comment"></span> <span class="keywordflow">for</span> (uint64_t i = 0; i <= m; i++) {</div>
|
||||
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">for</span> (uint64_t j = 0; j <= n; j++) {<span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 104</span><span class="comment"> /// If first string is empty, only option is to</span></div>
|
||||
<div class="line"><span class="lineno"> 105</span><span class="comment"> /// insert all characters of second string</span></div>
|
||||
<div class="line"><span class="lineno"> 106</span><span class="comment"></span> <span class="keywordflow">if</span> (i == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 107</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = j; <span class="comment">/// Minimum operations = j</span></div>
|
||||
<div class="line"><span class="lineno"> 99</span> 1)); </div>
|
||||
<div class="line"><span class="lineno"> 100</span> </div>
|
||||
<div class="line"><span class="lineno"> 102</span> <span class="keywordflow">for</span> (uint64_t i = 0; i <= m; i++) {</div>
|
||||
<div class="line"><span class="lineno"> 103</span> <span class="keywordflow">for</span> (uint64_t j = 0; j <= n; j++) {</div>
|
||||
<div class="line"><span class="lineno"> 106</span> <span class="keywordflow">if</span> (i == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 107</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = j; </div>
|
||||
<div class="line"><span class="lineno"> 108</span> }</div>
|
||||
<div class="line"><span class="lineno"> 109</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 110</span><span class="comment"> /// If second string is empty, only option is to</span></div>
|
||||
<div class="line"><span class="lineno"> 111</span><span class="comment"> /// remove all characters of second string</span></div>
|
||||
<div class="line"><span class="lineno"> 112</span><span class="comment"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (j == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 113</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = i; <span class="comment">/// Minimum operations = i</span></div>
|
||||
<div class="line"><span class="lineno"> 109</span> </div>
|
||||
<div class="line"><span class="lineno"> 112</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (j == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 113</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = i; </div>
|
||||
<div class="line"><span class="lineno"> 114</span> }</div>
|
||||
<div class="line"><span class="lineno"> 115</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 116</span><span class="comment"> /// If last characters are same, ignore last char</span></div>
|
||||
<div class="line"><span class="lineno"> 117</span><span class="comment"> /// and recur for remaining string</span></div>
|
||||
<div class="line"><span class="lineno"> 118</span><span class="comment"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (str1[i - 1] == str2[j - 1]) {</div>
|
||||
<div class="line"><span class="lineno"> 115</span> </div>
|
||||
<div class="line"><span class="lineno"> 118</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (str1[i - 1] == str2[j - 1]) {</div>
|
||||
<div class="line"><span class="lineno"> 119</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j - 1];</div>
|
||||
<div class="line"><span class="lineno"> 120</span> }</div>
|
||||
<div class="line"><span class="lineno"> 121</span><span class="comment"></span> </div>
|
||||
<div class="line"><span class="lineno"> 122</span><span class="comment"> /// If the last character is different, consider all</span></div>
|
||||
<div class="line"><span class="lineno"> 123</span><span class="comment"> /// possibilities and find the minimum</span></div>
|
||||
<div class="line"><span class="lineno"> 124</span><span class="comment"></span> <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 125</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = 1 + <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min.html">min</a>(<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j - 1], <span class="comment">// Insert</span></div>
|
||||
<div class="line"><span class="lineno"> 121</span> </div>
|
||||
<div class="line"><span class="lineno"> 124</span> <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 125</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = 1 + min(<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j - 1], <span class="comment">// Insert</span></div>
|
||||
<div class="line"><span class="lineno"> 126</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j], <span class="comment">// Remove</span></div>
|
||||
<div class="line"><span class="lineno"> 127</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j - 1]); <span class="comment">// Replace</span></div>
|
||||
<div class="line"><span class="lineno"> 128</span> }</div>
|
||||
<div class="line"><span class="lineno"> 129</span> }</div>
|
||||
<div class="line"><span class="lineno"> 130</span> }</div>
|
||||
<div class="line"><span class="lineno"> 131</span> </div>
|
||||
<div class="line"><span class="lineno"> 132</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[m][n]; <span class="comment">/// returning the minimum cost of operations needed to</span><span class="comment"></span></div>
|
||||
<div class="line"><span class="lineno"> 133</span><span class="comment"> /// convert str1 to str2</span></div>
|
||||
<div class="line"><span class="lineno"> 134</span><span class="comment"></span>}</div>
|
||||
<div class="ttc" id="amin_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/min.html">std::min</a></div><div class="ttdeci">T min(T... args)</div></div>
|
||||
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> partition_problem.cpp:39</div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
|
||||
<div class="line"><span class="lineno"> 132</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[m][n]; </div>
|
||||
<div class="line"><span class="lineno"> 134</span>}</div>
|
||||
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> <a href="../../de/d8c/partition__problem_8cpp_source.html#l00039">partition_problem.cpp:39</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -285,17 +295,14 @@ Algorithm</h3>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="section return"><dt>Returns</dt><dd>0 on exit </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00173">173</a> of file <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html">minimum_edit_distance.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 173</span> {</div>
|
||||
<div class="line"><span class="lineno"> 174</span> <a class="code hl_function" href="#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><span class="lineno"> 175</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 176</span>}</div>
|
||||
<div class="ttc" id="aminimum__edit__distance_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> minimum_edit_distance.cpp:142</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d52/minimum__edit__distance_8cpp_a0ddf1224851353fc92bfbff6f499fa97_cgraph.svg" width="322" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aminimum__edit__distance_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> <a href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00142">minimum_edit_distance.cpp:142</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a0138c226bd79ffe6d839c787cfc60347" name="a0138c226bd79ffe6d839c787cfc60347"></a>
|
||||
@@ -339,14 +346,16 @@ z if <code>z</code> 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>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00068">68</a> of file <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html">minimum_edit_distance.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 68</span> {</div>
|
||||
<div class="line"><span class="lineno"> 69</span> <span class="keywordflow">if</span> (x <= y && x <= z) {</div>
|
||||
<div class="line"><span class="lineno"> 70</span> <span class="keywordflow">return</span> x; <span class="comment">/// returns x, if x is the minimum value</span></div>
|
||||
<div class="line"><span class="lineno"> 70</span> <span class="keywordflow">return</span> x; </div>
|
||||
<div class="line"><span class="lineno"> 71</span> }</div>
|
||||
<div class="line"><span class="lineno"> 72</span> <span class="keywordflow">if</span> (y <= x && y <= z) {</div>
|
||||
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">return</span> y; <span class="comment">/// returns y, if y is the minimum value</span></div>
|
||||
<div class="line"><span class="lineno"> 73</span> <span class="keywordflow">return</span> y; </div>
|
||||
<div class="line"><span class="lineno"> 74</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">return</span> z; <span class="comment">/// returns z if z is the minimum value</span></div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">return</span> z; </div>
|
||||
<div class="line"><span class="lineno"> 76</span> }</div>
|
||||
<div class="line"><span class="lineno"> 77</span>}</div>
|
||||
</div><!-- fragment -->
|
||||
@@ -377,41 +386,34 @@ z if <code>z</code> is the minimum value </dd></dl>
|
||||
|
||||
<p>Self-test implementations. </p>
|
||||
<dl class="section return"><dt>Returns</dt><dd>void </dd></dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00142">142</a> of file <a class="el" href="../../da/d52/minimum__edit__distance_8cpp_source.html">minimum_edit_distance.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 142</span> {</div>
|
||||
<div class="line"><span class="lineno"> 143</span> <span class="comment">// 1st test</span></div>
|
||||
<div class="line"><span class="lineno"> 144</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str1 = <span class="stringliteral">"INTENTION"</span>; <span class="comment">// Sample input of 1st string</span></div>
|
||||
<div class="line"><span class="lineno"> 145</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str2 = <span class="stringliteral">"EXECUTION"</span>; <span class="comment">// Sample input of 2nd string</span></div>
|
||||
<div class="line"><span class="lineno"> 144</span> std::string str1 = <span class="stringliteral">"INTENTION"</span>; <span class="comment">// Sample input of 1st string</span></div>
|
||||
<div class="line"><span class="lineno"> 145</span> std::string str2 = <span class="stringliteral">"EXECUTION"</span>; <span class="comment">// Sample input of 2nd string</span></div>
|
||||
<div class="line"><span class="lineno"> 146</span> uint64_t expected_output1 = 5; <span class="comment">// Expected minimum cost</span></div>
|
||||
<div class="line"><span class="lineno"> 147</span> uint64_t output1 = <a class="code hl_function" href="#ade2fcfe0359f3c7691bfaa04b14943e2">dynamic_programming::minimum_edit_distance::editDistDP</a>(</div>
|
||||
<div class="line"><span class="lineno"> 148</span> str1, str2, str1.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>(),</div>
|
||||
<div class="line"><span class="lineno"> 149</span> str2.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>()); <span class="comment">// calling the editDistDP function and storing the</span></div>
|
||||
<div class="line"><span class="lineno"> 148</span> str1, str2, str1.length(),</div>
|
||||
<div class="line"><span class="lineno"> 149</span> str2.length()); <span class="comment">// calling the editDistDP function and storing the</span></div>
|
||||
<div class="line"><span class="lineno"> 150</span> <span class="comment">// result on output1</span></div>
|
||||
<div class="line"><span class="lineno"> 151</span> assert(output1 ==</div>
|
||||
<div class="line"><span class="lineno"> 152</span> expected_output1); <span class="comment">// comparing the output with the expected output</span></div>
|
||||
<div class="line"><span class="lineno"> 153</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output1</div>
|
||||
<div class="line"><span class="lineno"> 154</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 153</span> std::cout << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output1</div>
|
||||
<div class="line"><span class="lineno"> 154</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 155</span> </div>
|
||||
<div class="line"><span class="lineno"> 156</span> <span class="comment">// 2nd test</span></div>
|
||||
<div class="line"><span class="lineno"> 157</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str3 = <span class="stringliteral">"SATURDAY"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 158</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a> str4 = <span class="stringliteral">"SUNDAY"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 157</span> std::string str3 = <span class="stringliteral">"SATURDAY"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 158</span> std::string str4 = <span class="stringliteral">"SUNDAY"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 159</span> uint64_t expected_output2 = 3;</div>
|
||||
<div class="line"><span class="lineno"> 160</span> uint64_t output2 = <a class="code hl_function" href="#ade2fcfe0359f3c7691bfaa04b14943e2">dynamic_programming::minimum_edit_distance::editDistDP</a>(</div>
|
||||
<div class="line"><span class="lineno"> 161</span> str3, str4, str3.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>(), str4.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">length</a>());</div>
|
||||
<div class="line"><span class="lineno"> 161</span> str3, str4, str3.length(), str4.length());</div>
|
||||
<div class="line"><span class="lineno"> 162</span> assert(output2 == expected_output2);</div>
|
||||
<div class="line"><span class="lineno"> 163</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output2</div>
|
||||
<div class="line"><span class="lineno"> 164</span> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 163</span> std::cout << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output2</div>
|
||||
<div class="line"><span class="lineno"> 164</span> << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 165</span>}</div>
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="abasic_string_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string.html">std::string</a></div></div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
<div class="ttc" id="aminimum__edit__distance_8cpp_html_ade2fcfe0359f3c7691bfaa04b14943e2"><div class="ttname"><a href="#ade2fcfe0359f3c7691bfaa04b14943e2">dynamic_programming::minimum_edit_distance::editDistDP</a></div><div class="ttdeci">uint64_t editDistDP(std::string str1, std::string str2, uint64_t m, uint64_t n)</div><div class="ttdoc">Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute t...</div><div class="ttdef"><b>Definition</b> minimum_edit_distance.cpp:92</div></div>
|
||||
<div class="ttc" id="asize_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/string/basic_string/size.html">std::string::length</a></div><div class="ttdeci">T length(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../da/d52/minimum__edit__distance_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width="224" height="86"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="aminimum__edit__distance_8cpp_html_ade2fcfe0359f3c7691bfaa04b14943e2"><div class="ttname"><a href="#ade2fcfe0359f3c7691bfaa04b14943e2">dynamic_programming::minimum_edit_distance::editDistDP</a></div><div class="ttdeci">uint64_t editDistDP(std::string str1, std::string str2, uint64_t m, uint64_t n)</div><div class="ttdoc">Calculates and stores the result of all the sub-problems, so that we don't have to recur to compute t...</div><div class="ttdef"><b>Definition</b> <a href="../../da/d52/minimum__edit__distance_8cpp_source.html#l00092">minimum_edit_distance.cpp:92</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<map id="main" name="main">
|
||||
<area shape="rect" id="Node000001" title="main function" alt="" coords="5,31,55,56"/>
|
||||
<area shape="rect" id="Node000002" href="$da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" title="Self-test implementations." alt="" coords="103,31,146,56"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="55,41,87,41,87,46,55,46"/>
|
||||
<area shape="rect" id="Node000003" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="220,5,291,31"/>
|
||||
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="146,37,204,25,205,31,147,42"/>
|
||||
<area shape="rect" id="Node000004" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/basic_string/size.html#" title=" " alt="" coords="194,55,316,80"/>
|
||||
<area shape="poly" id="edge3_Node000002_Node000004" title=" " alt="" coords="147,45,179,51,178,56,146,50"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
47edd03b069725b7fec56bef0e6b0ab5
|
||||
@@ -1,101 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="241pt" height="64pt"
|
||||
viewBox="0.00 0.00 241.25 64.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 60.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="main function">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-37.25 0,-37.25 0,-18 37,-18 37,-37.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" target="_top" xlink:title="Self-test implementations.">
|
||||
<polygon fill="white" stroke="#666666" points="105.5,-37.25 73,-37.25 73,-18 105.5,-18 105.5,-37.25"/>
|
||||
<text text-anchor="middle" x="89.25" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.2,-27.62C44.58,-27.62 53.31,-27.62 61.45,-27.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.2,-31.13 71.2,-27.63 61.2,-24.13 61.2,-31.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="214.12,-56.25 160.62,-56.25 160.62,-37 214.12,-37 214.12,-56.25"/>
|
||||
<text text-anchor="middle" x="187.38" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M105.69,-30.68C117.45,-33 134.14,-36.3 149.29,-39.29"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="148.49,-42.7 158.98,-41.21 149.85,-35.84 148.49,-42.7"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node4 -->
|
||||
<g id="Node000004" class="node">
|
||||
<title>Node4</title>
|
||||
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/string/basic_string/size.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="233.25,-19.25 141.5,-19.25 141.5,0 233.25,0 233.25,-19.25"/>
|
||||
<text text-anchor="middle" x="187.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::string::length</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node4 -->
|
||||
<g id="edge3_Node000002_Node000004" class="edge">
|
||||
<title>Node2->Node4</title>
|
||||
<g id="a_edge3_Node000002_Node000004"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M105.69,-24.73C112.49,-23.46 120.92,-21.88 129.76,-20.23"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="130.4,-23.67 139.58,-18.39 129.11,-16.79 130.4,-23.67"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.1 KiB |
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="241pt" height="64pt"
|
||||
viewBox="0.00 0.00 241.25 64.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 60.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="main function">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-37.25 0,-37.25 0,-18 37,-18 37,-37.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d" target="_top" xlink:title="Self-test implementations.">
|
||||
<polygon fill="white" stroke="#666666" points="105.5,-37.25 73,-37.25 73,-18 105.5,-18 105.5,-37.25"/>
|
||||
<text text-anchor="middle" x="89.25" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.2,-27.62C44.58,-27.62 53.31,-27.62 61.45,-27.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.2,-31.13 71.2,-27.63 61.2,-24.13 61.2,-31.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="214.12,-56.25 160.62,-56.25 160.62,-37 214.12,-37 214.12,-56.25"/>
|
||||
<text text-anchor="middle" x="187.38" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M105.69,-30.68C117.45,-33 134.14,-36.3 149.29,-39.29"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="148.49,-42.7 158.98,-41.21 149.85,-35.84 148.49,-42.7"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node4 -->
|
||||
<g id="Node000004" class="node">
|
||||
<title>Node4</title>
|
||||
<g id="a_Node000004"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/string/basic_string/size.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="233.25,-19.25 141.5,-19.25 141.5,0 233.25,0 233.25,-19.25"/>
|
||||
<text text-anchor="middle" x="187.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::string::length</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node4 -->
|
||||
<g id="edge3_Node000002_Node000004" class="edge">
|
||||
<title>Node2->Node4</title>
|
||||
<g id="a_edge3_Node000002_Node000004"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M105.69,-24.73C112.49,-23.46 120.92,-21.88 129.76,-20.23"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="130.4,-23.67 139.58,-18.39 129.11,-16.79 130.4,-23.67"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,7 +0,0 @@
|
||||
<map id="test" name="test">
|
||||
<area shape="rect" id="Node000001" title="Self-test implementations." alt="" coords="5,31,49,56"/>
|
||||
<area shape="rect" id="Node000002" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/io/manip/endl.html#" title=" " alt="" coords="122,5,194,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="48,37,107,25,108,31,49,42"/>
|
||||
<area shape="rect" id="Node000003" href="/Users/runner/work/C-Plus-Plus/C-Plus-Plus/doc/cppreference-doxygen-web.tag.xml$cpp/string/basic_string/size.html#" title=" " alt="" coords="97,55,219,80"/>
|
||||
<area shape="poly" id="edge2_Node000001_Node000003" title=" " alt="" coords="49,45,82,51,81,56,48,50"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
07b428c2c3526928ee1215ab64993828
|
||||
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: test Pages: 1 -->
|
||||
<svg width="168pt" height="64pt"
|
||||
viewBox="0.00 0.00 168.25 64.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 60.25)">
|
||||
<title>test</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Self-test implementations.">
|
||||
<polygon fill="#999999" stroke="#666666" points="32.5,-37.25 0,-37.25 0,-18 32.5,-18 32.5,-37.25"/>
|
||||
<text text-anchor="middle" x="16.25" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="141.12,-56.25 87.62,-56.25 87.62,-37 141.12,-37 141.12,-56.25"/>
|
||||
<text text-anchor="middle" x="114.38" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M32.69,-30.68C44.45,-33 61.14,-36.3 76.29,-39.29"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="75.49,-42.7 85.98,-41.21 76.85,-35.84 75.49,-42.7"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/string/basic_string/size.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="160.25,-19.25 68.5,-19.25 68.5,0 160.25,0 160.25,-19.25"/>
|
||||
<text text-anchor="middle" x="114.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::string::length</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge2_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M32.69,-24.73C39.49,-23.46 47.92,-21.88 56.76,-20.23"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="57.4,-23.67 66.58,-18.39 56.11,-16.79 57.4,-23.67"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: test Pages: 1 -->
|
||||
<svg width="168pt" height="64pt"
|
||||
viewBox="0.00 0.00 168.25 64.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 60.25)">
|
||||
<title>test</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title="Self-test implementations.">
|
||||
<polygon fill="#999999" stroke="#666666" points="32.5,-37.25 0,-37.25 0,-18 32.5,-18 32.5,-37.25"/>
|
||||
<text text-anchor="middle" x="16.25" y="-23.75" font-family="Helvetica,sans-Serif" font-size="10.00">test</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/io/manip/endl.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="141.12,-56.25 87.62,-56.25 87.62,-37 141.12,-37 141.12,-56.25"/>
|
||||
<text text-anchor="middle" x="114.38" y="-42.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::endl</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M32.69,-30.68C44.45,-33 61.14,-36.3 76.29,-39.29"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="75.49,-42.7 85.98,-41.21 76.85,-35.84 75.49,-42.7"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a target="_blank" xlink:href="http://en.cppreference.com/w/cpp/string/basic_string/size.html#" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="160.25,-19.25 68.5,-19.25 68.5,0 160.25,0 160.25,-19.25"/>
|
||||
<text text-anchor="middle" x="114.38" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">std::string::length</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node3 -->
|
||||
<g id="edge2_Node000001_Node000003" class="edge">
|
||||
<title>Node1->Node3</title>
|
||||
<g id="a_edge2_Node000001_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M32.69,-24.73C39.49,-23.46 47.92,-21.88 56.76,-20.23"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="57.4,-23.67 66.58,-18.39 56.11,-16.79 57.4,-23.67"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.5 KiB |
234
da/d52/minimum__edit__distance_8cpp_source.html
Normal file
234
da/d52/minimum__edit__distance_8cpp_source.html
Normal file
@@ -0,0 +1,234 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<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.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: dynamic_programming/minimum_edit_distance.cpp Source File</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<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>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.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 */
|
||||
</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 -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('da/d52/minimum__edit__distance_8cpp_source.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">minimum_edit_distance.cpp</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<a href="../../da/d52/minimum__edit__distance_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="preprocessor">#include <cassert></span> </div>
|
||||
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span><span class="preprocessor">#include <cstdint></span> </div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span><span class="preprocessor">#include <iostream></span> </div>
|
||||
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span><span class="preprocessor">#include <vector></span> </div>
|
||||
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
|
||||
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a> {</div>
|
||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> </div>
|
||||
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span><span class="keyword">namespace </span>minimum_edit_distance {</div>
|
||||
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> </div>
|
||||
<div class="foldopen" id="foldopen00068" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"><a class="line" href="../../da/d52/minimum__edit__distance_8cpp.html#a0138c226bd79ffe6d839c787cfc60347"> 68</a></span>uint64_t min(uint64_t x, uint64_t y, uint64_t z) {</div>
|
||||
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <span class="keywordflow">if</span> (x <= y && x <= z) {</div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <span class="keywordflow">return</span> x; </div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> }</div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="keywordflow">if</span> (y <= x && y <= z) {</div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="keywordflow">return</span> y; </div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> } <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordflow">return</span> z; </div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> }</div>
|
||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> </div>
|
||||
<div class="foldopen" id="foldopen00092" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"><a class="line" href="../../da/d52/minimum__edit__distance_8cpp.html#ade2fcfe0359f3c7691bfaa04b14943e2"> 92</a></span>uint64_t editDistDP(std::string str1, std::string str2, uint64_t m,</div>
|
||||
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> uint64_t n) {</div>
|
||||
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> std::vector<std::vector<uint64_t>> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>(</div>
|
||||
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> m + 1,</div>
|
||||
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> std::vector<uint64_t>(</div>
|
||||
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> n +</div>
|
||||
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> 1)); </div>
|
||||
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> </div>
|
||||
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> <span class="keywordflow">for</span> (uint64_t i = 0; i <= m; i++) {</div>
|
||||
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="keywordflow">for</span> (uint64_t j = 0; j <= n; j++) {</div>
|
||||
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <span class="keywordflow">if</span> (i == 0) {</div>
|
||||
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = j; </div>
|
||||
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> }</div>
|
||||
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> </div>
|
||||
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (j == 0) {</div>
|
||||
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = i; </div>
|
||||
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> }</div>
|
||||
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> </div>
|
||||
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (str1[i - 1] == str2[j - 1]) {</div>
|
||||
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j - 1];</div>
|
||||
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> }</div>
|
||||
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> </div>
|
||||
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="keywordflow">else</span> {</div>
|
||||
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j] = 1 + min(<a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i][j - 1], <span class="comment">// Insert</span></div>
|
||||
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j], <span class="comment">// Remove</span></div>
|
||||
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[i - 1][j - 1]); <span class="comment">// Replace</span></div>
|
||||
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> }</div>
|
||||
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> }</div>
|
||||
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span> }</div>
|
||||
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> </div>
|
||||
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <span class="keywordflow">return</span> <a class="code hl_namespace" href="../../df/d88/namespacedp.html">dp</a>[m][n]; </div>
|
||||
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span>} <span class="comment">// namespace minimum_edit_distance</span></div>
|
||||
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span>} <span class="comment">// namespace dynamic_programming</span></div>
|
||||
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> </div>
|
||||
<div class="foldopen" id="foldopen00142" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"><a class="line" href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d"> 142</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>() {</div>
|
||||
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <span class="comment">// 1st test</span></div>
|
||||
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> std::string str1 = <span class="stringliteral">"INTENTION"</span>; <span class="comment">// Sample input of 1st string</span></div>
|
||||
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> std::string str2 = <span class="stringliteral">"EXECUTION"</span>; <span class="comment">// Sample input of 2nd string</span></div>
|
||||
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> uint64_t expected_output1 = 5; <span class="comment">// Expected minimum cost</span></div>
|
||||
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> uint64_t output1 = dynamic_programming::minimum_edit_distance::editDistDP(</div>
|
||||
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> str1, str2, str1.length(),</div>
|
||||
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> str2.length()); <span class="comment">// calling the editDistDP function and storing the</span></div>
|
||||
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <span class="comment">// result on output1</span></div>
|
||||
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> assert(output1 ==</div>
|
||||
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> expected_output1); <span class="comment">// comparing the output with the expected output</span></div>
|
||||
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> std::cout << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output1</div>
|
||||
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> </div>
|
||||
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <span class="comment">// 2nd test</span></div>
|
||||
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> std::string str3 = <span class="stringliteral">"SATURDAY"</span>;</div>
|
||||
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> std::string str4 = <span class="stringliteral">"SUNDAY"</span>;</div>
|
||||
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> uint64_t expected_output2 = 3;</div>
|
||||
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> uint64_t output2 = dynamic_programming::minimum_edit_distance::editDistDP(</div>
|
||||
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> str3, str4, str3.length(), str4.length());</div>
|
||||
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> assert(output2 == expected_output2);</div>
|
||||
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> std::cout << <span class="stringliteral">"Minimum Number of Operations Required: "</span> << output2</div>
|
||||
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> </div>
|
||||
<div class="foldopen" id="foldopen00173" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"><a class="line" href="../../da/d52/minimum__edit__distance_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97"> 173</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) {</div>
|
||||
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span> <a class="code hl_function" href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run self-test implementations</span></div>
|
||||
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno"> 175</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span>}</div>
|
||||
</div>
|
||||
<div class="ttc" id="agenerate__parentheses_8cpp_html_gae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Main function.</div><div class="ttdef"><b>Definition</b> <a href="../../dd/d1e/generate__parentheses_8cpp_source.html#l00110">generate_parentheses.cpp:110</a></div></div>
|
||||
<div class="ttc" id="aminimum__edit__distance_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../da/d52/minimum__edit__distance_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">Self-test implementations.</div><div class="ttdef"><b>Definition</b> <a href="#l00142">minimum_edit_distance.cpp:142</a></div></div>
|
||||
<div class="ttc" id="anamespacedp_html"><div class="ttname"><a href="../../df/d88/namespacedp.html">dp</a></div><div class="ttdoc">for std::vector</div><div class="ttdef"><b>Definition</b> <a href="../../de/d8c/partition__problem_8cpp_source.html#l00039">partition_problem.cpp:39</a></div></div>
|
||||
<div class="ttc" id="anamespacedynamic__programming_html"><div class="ttname"><a href="../../dd/d24/namespacedynamic__programming.html">dynamic_programming</a></div><div class="ttdoc">Dynamic Programming algorithms.</div></div>
|
||||
</div><!-- fragment --></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- 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.12.0 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user