In multi-user environment, practically, we have implemented ABTS and MGswapDD in lab using Qualnet and ASP.Net software.
Algorithm swapDD
Case 1:
If o
2
pos = o
1
.pos
In this case, swapDD fails at boundary condition means that if o2.pos = o1.pos, it fails totally (lines 2–3 of algorithm swapDD).
For example, let s = “TheGodHelpAllEqually.” Here, suppose o1 = delete(3, “GodHelp”) and o2 = delete(3, “God”). Therefore, condition at line 2 if(o
2
.pos ≥o
1
.pos) is true, since o2.pos = o1.pos, so by line 3, we get o2′.pos = o2.pos + |o1.str| so we get o2′.pos = 3+7 = 10. Here, in given string definition s, we apply o2′ = delete(10, “God”); the operation fails since at starting position ‘10’ substring “God” not found (see Fig. 2). Therefore, swapDD fails totally.
If we implement new proposed MGswapDD for the same inputs like case 1, we get o1′ = o1 and o2′ = null, so get right input because if o1′ get executed, then no need to execute o2′ because o2 string get deleted by o1′ since o2 string is overlapped by o1 string (see Fig. 3).
Case 2:
If there exist partial overlapping between deletion operations o1 and o2 regions
Here, partial overlapping between o1 and o2 means region of o1 and o2 overlaps to each other.
For example, let s = “TheBirdsAreFlyingInTheSky”
Let o1.str = “BirdsAreFlying” and o1.pos = 3,|o1.str| = 14
o2.str = “FlyingInTheSky” and o2.pos = 11.
Here, o1 overlaps with o2 along its right boundary. And if we execute swapDD; condition at line 2 is correct that is (o2.pos ≥o1.pos), since 11 > 3, so enter in if block and execute the code at line 3 that are o2′.pos = o2.pos + |o1.str|, so here, we get o2′.pos = 11 + 14 = 25, so we get o2′ = delete (25, “FlyingInTheSky”). The operation o2′ fails since at starting position ‘25’ substring “FlyingInTheSky” not found. Even position ‘25’ not exist in given ‘s’. Thus, swapDD fails totally (see Fig. 4).
When we implement MGswapDD in lab practically for inputs of case 2, we get o1′ = o1. o2′.pos = 17 and o2′.str=‘‘InTheSky” which give right output, because there exist no overlapping in o1′ and o2′ and both lie at given position in string ‘s’ (see Fig. 5).
Case 3:
If o
1.
str completely overlaps by o
2
.str
In this case, swapDD lines 6–13 get executed and it gives total wrong output in all cases.
For example, s = “WorkNotO nlyHardButGoodAlso”.
Let o1 = delete(7, “Only”); o2 = delete(4, “NotOnlyHard”)
Here, on executing swapDD lines 6–13, it will get executed, and we get from line7: o2L ← o2 and o2R ← o2. From line 8: o2L.str ← o2.str [0:o1.pos−o2.pos], so we get o2L.str ← o2.str [0:7−4] = “Not”;
Also from line 9, we get o2R.pos ← o1.pos + |o1.str|; so we get o2R.pos ← 7 + 4 = 11. And from Line 10 we get o2R.str ← o2.str [o1.pos−o2.pos:]; so we get o2R.str ← o2.str[7 − 4:]; so we get o2R.str ← “OnlyHard”. Therefore, we get o2R = delete (11, “OnlyHard”) but in given ‘s’ at position 11 “OnlyHard” not exist so o2′.sol ← [o2L, o2R] also fails totally (see Fig. 6).
When we practically implemented MGswapDD in lab for inputs of case 3, we get o1′.str = o1.str and o1′.pos = 4. We get o2L’.str = “Not” and o2L’.pos = 4, o2R’.str = ‘‘Hard”, o2R’.pos = 11 which give desired output, because o1 overlapped completely by o2 and overlapped region of o2 get deleted by o1′ so o2′ split in o2L’ and o2R’ to get desired output (see Fig. 7).
Case 4:
If o2.str completely overlaps by o1.str
If o2.str completely overlaps by o1.str, then in this case, swapDD lines 2–3 get executed and it gives total wrong output in all cases.
For example:
Let s = “GodHelpThoseWhoHelpThemselves”
o2 = delete (12, “Who”);
o1 = delete (3, “HelpThoseWhoHelp”);
Here on executing swapDD lines 2–3 will get executed and we get wrong output.
o1’ = “HelpThoseWhoHelp” o1’ position = 3 o2’ = “Who” o2’ position = 28
Algorithm swapDD failed. Thus, o2′.sol ← [o2L, o2R] fails totally (see Fig. 8).
When we practical implement MGswapDD in lab for inputs of case 4, we get o1′.pos = “HelpThoseWhoHelp” and o1′.pos = 3. Also o2′ = null, because o2 overlapped by o1 and o1′ delete the overlapped region so no need to execute o2′ (see Fig. 9).
Algorithm MGswapDD
Case 1:
If o2.pos = o1.pos
Here, in this case on executing MGswapDD lines 13–25, it will get executed and will give right result.
For example, let s = “TheBirdsAreFlyingInTheSky”
o1 = delete(3, “BirdsAreFlying”); o2 = delete(3, “Birds”)
Condition at line 14 is correct so switch to line 15. Condition if (((o1.pos + |o1.str|) ≥(o2.pos + |o2.str|))&& (o1.pos ≤ o2.pos)). Here, we get if((3 + 14) ≥ (3 + 5)&&3 ≤3) returns true so code at line 15 that is o2′ ← null get executed means o2′ will not execute any operation both its string and position are null. And o1′ ← o1 from line 1, so we get desired output “TheInTheSky” after execution of o1′ and o2′ where o2′ is null. It satisfies user intentions also (see Fig. 10).
Case 2:
If there exist partial overlapping between deletion operations o1 and o2 regions
Here, two cases are possible either o1.str overlaps with o2.str along its right border or left border.
First, we consider the case when o1.str overlaps with o2.str along its rightboundary. For example, let s = “GodPleaseHelpMeToTakeCareMyChild”.
o1 = (3, “PleaseHelpMe”); |o1.str| = 12 and |o2.str| = 12; o2 = delete(13, “MeToTakeCare”); o1.pos = 3 and o2.pos = 13.
Since on executing MGswapDD condition at line 7 is true that is if (o2.pos > o1.pos&&o2.pos ≤(o1.pos +|o1.str|) && (o2.pos + |o2.str|) > (o1.pos + |o1.str|)) returns true, so lines 8 and 9 will get executed.
Step 8: o2′.pos = o2.pos + ((o1.pos + |o1.str|)−o2.pos);
Step 9: o2′.str = o2.Substring ((o1.pos + |o1.str|)−o2.pos);
From step 8, o2′.pos = 13 + (3 + 12)−13; o2′ = 15;
Step 9: o2′.str = o2.Substring (3 + 12−13) = o2.Substring(2), so o2′.str = “ToTakeCare”. We get o2′ = delete (15, “ToTakeCare”) and it runs well since at position 15 “ToTakeCare” exist in given ‘s’. Therefore, the overlapped substring “Me” get deleted by o1′ and o2′ has deleted just unoverlapped part of o2. Here, o1′ ← o1 from line 1. So again, we get totally right output satisfying user intentions (see Fig. 11).
Second, we consider the case when o1.str overlaps with o2.str along its left boundary.
For example, let s = “GodPleaseHelpMeToTakeCareMyChild”.
o2 = (3, “PleaseHelpMe”); |o2.str| = 12 and |o1.str| = 12; o1 = delete(13, “MeToTakeCare”); o2.pos = 3 and o1.pos = 13. Since on executing MGswapDD condition at line 10 is true that is so the given code will get executed. Therefore, condition at line 10 is as follows: if(o2.pos < o1.pos&&(o2.pos + |o2.str|) ≥ o1.pos && o1.pos + |o1.str| > (o2.pos + |o2.str|)) returns true so from Step 11: o2′.str = o2.Substring (0, (o1.pos−o2.pos)); so we get o2′.str = o2.Substring (0,(13−3)) = “PleaseHelp”; here |o2′.str| = 10; and from step Step 12: o1′.pos = o1.pos−|o2′.str|; we get o1′.pos = 13−10 = 3. Since after deletion by o2′ the o1′. pos should left by the length of o2′.str as o2′ lies left of o1′ and is already deleted. Here, we get finally o1′ = delete(3, “PleaseHelpMe”) and o2′ = delete(15, “ToTakeCare”) and o2′ → o1′ work well after swapping of o1 → o2.
In this case, also we get right output.
Case 3:
If o
1.
str completely overlaps by o
2
.str
In this case, all the above conditions before line 13 are false so enter in else block at line 13. Here, condition at Step 14: if(((o1.pos + |o1.str|) ≥ (o2.pos + |o2.str|))&& (o1.pos ≤ o2.pos)) is false so enter in its else part. So lines 16 to 25 get executed.
For example, let s = “The Sun give us Heat and Light”; o1 = delete(13, “us”) and o2 = delete(4, “Sun give us Heat”). From Step 17: o2Lpart ← o2; o2Lpart.str = o2.str; here, we have o2Lpart.str = “Sun give us Heat”. From Step 18: o2Lpart.pos = o2.pos; Here we have o2Lpart.pos = 4. From Step 19: o2Rpart ← o2; o2Rpart.str = o2.str; here, we have o2Rpart.str = “Sun give us Heat”. From Step 20: o2Rpart.pos = o2.pos; here, we have o2Rpart.pos = 4.
From Step 21: o2Lpart.str = o2.Substring (0, o1.pos−o2.pos); here, we have o2Lpart.str = o2.Substring (0,13−4) ≥ o2Lpart.str = o2.Substring (0,9) = “Sun give”. From Step 22: o2Rpart.pos = o1.pos + |o1.str|; here, we have o2Rpart.pos = 13 + 2=15. From Step 23: o2Rpart.str = o2.Substring (o1.pos−o2.pos + |o1.str|); here, we have o2Rpart.str = o2.Substring (13−4 + 2) = o2.Substring (11) = “Heat”. From Step 24: o2′.sol ← [o2Lpart, o2Rpart]; so the left part “Sun give”. get deleted by operation o2Lpart;right part “Heat” get deleted by o2Rpart and the middle overlapping región “us” get deleted by o1 and by Step 25: o1′.pos = o2.pos;so we get o1′.pos = 4 since at first o2′ get executed and since o2Lpart is already executed the position of o1′ shift left to o2.pos. So o2′ → o1′ works correctly here (see Fig. 12).
Case 4:
If o
2.
str completely overlaps by o
1
.str
In this case, all the above conditions before line 13 are false so enter in else block at line 13. Here, condition at Step 14: if (((o1.pos + |o1.str|) ≥ (o2.pos + |o2.str|))&& (o1.pos ≤ o2.pos)) is true so enter in its if part. So step 15 will get executed.
For example, let s = “The God will help me always everywhere”. o1 = delete (4, “God will help me”) and o2 = delete (8, “will”). Here, condition at Step 14: if(((o1.pos + |o1.str|) ≥ (o2.pos + |o2.str|))&&(o1.pos ≤o2.pos)) that is if((4 + 15) ≥ (8 + 4)&&4 ≤8) is true so condition at line 15 get executed where o2′ is set to null means will not perform any operation and o1 will remain as it is. If o1 will execute the region of o2 which is covered by o1 will automatically deleted giving right output. Here, o2′ → o1′ is equal to execution of o1′ only, since o2′ is null and also o1′ ← o1 from line 1 (see Fig. 13).