Algorithm 2
TEXT LINE EDITING
(Computational Thinking)
Unit - 5
Dept. of CSE
PVPSIT, Kanuru.
Department of CSE
2025-26
Algorithm 2
TEXT LINE EDITING
PVPSIT (Autonomous)
Problem Solving Techniques
“the two wrongs in this line are wrong” (original)
“the two rights in this line are right” (edited line)
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
(a) When a mismatch copy from the original line.
(b) When a complete match copy from new pattern.
newtext[k] := txt[i]
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
if (wpattern[j] == Text[i+j-1]) then
j:= j+1
if (j == patlength+1) then
j:=1; k = 1
while (k <= patlength) do
Text[i]:=rpattern[k];
i := i+1;
k := k+1;
else
i := i+1
j := 1
Department of CSE
2025-26
Pseudocode
PVPSIT (Autonomous)
Problem Solving Techniques
Step 3.1: if (wpattern[j] == text[i+j-1]) then do Steps 3.1.1 and 3.1.2 else go to 3.2
Step 3.1.1: j := j+1
Step 3.1.2: if (j == patlength+1) then do Steps 3.1.2.1 and 3.1.2.2
Step 3.1.2.1: j := 1; k := 1
Step 3.1.2.2: Repeat Steps 3.1.2.2.1, 3.1.2.2.2 and 3.1.2.2.3 till (k <= patlength)
Step 3.1.2.2.1: text[i]:=rpattern[k];
Step 3.1.2.2.2: i++;
Step 3.1.2.2.3: k++;
Step 3.2: j:=1;
Step 3.3: i:= i+1;
Department of CSE
2025-26
Algorithm
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
PVPSIT (Autonomous)
Problem Solving Techniques
Department of CSE
2025-26
Supplementary problems (6.4.1)
PVPSIT (Autonomous)
Problem Solving Techniques