Write an algorithm that deletes every occurrences of a pattern ‘P’ in a text ‘T’.
Write an algorithm that deletes every occurrences of a pattern ‘P’ in a text ‘T’.
Answer:
Algorithm ( Delete)
A text T and pattern
P are in memory. This algorithm deletes every occurrence of P in T.
1.
K:= INDEX( T,P).
2.
While ( k ≠ 0)
(a)
DELETE ( T, P), LENGTH (P) )
(b)
K= INDEX (T,P)
[End of Loop]
3.
Write: T.
Exit.
No comments
Dear Members, Thanks for Your Comments. We must be reply your comment answer as soon as possible. Please Stay with us.....