mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-05 04:32:56 +08:00
Documentation for 0c5c096991
This commit is contained in:
@@ -137,7 +137,7 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Implementation of <a href="https://en.wikipedia.org/wiki/Edit_distance">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_md57"></a>
|
||||
<h3><a class="anchor" id="autotoc_md63"></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>
|
||||
|
||||
@@ -137,7 +137,7 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Implementation of singly linked list algorithm. </p>
|
||||
<p>The linked list is a data structure used for holding a sequence of values, which can be added, removed and displayed. </p>
|
||||
<h3><a class="anchor" id="autotoc_md27"></a>
|
||||
<h3><a class="anchor" id="autotoc_md33"></a>
|
||||
Algorithm</h3>
|
||||
<p>Values can be added by iterating to the end of a list(by following the pointers) starting from the first link. Whichever link points to null is considered the last link and is pointed to the new value.</p>
|
||||
<p>Values can be removed by also iterating through the list. When the node containing the value is found, the node pointing to the current node is made to point to the node that the current node is pointing to, and then returning the current node to heap store. </p>
|
||||
|
||||
Reference in New Issue
Block a user