Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
What are the different operations performed on strings in TOC?
A string is a finite set sequence of symbols choosen from some alphabets.
For example,
- 00011001 is a string from binary alphabet Σ={0,1}
- aabbcabcd is a string from alphabet Σ={a,b,c,d}
The different operations performed on strings are explained below −
- Concatenation.
- Substring.
- Kleen star operation.
- Reversal.
Concatenation
Concatenation is nothing but combining the two strings one after another.
Example
Let’s consider two strings −
X= Tutorials
Y= Point
The concatenation (X, Y) of two strings is −
X.Y = TutorialsPoint
Note − Concatenation of empty string with other string gives string itself.
For example, X. ε = ε.X = X
Substring
If ‘w’ is a string then ‘v’ is substring of ‘w’ if there exists string x and y such that w=xvy
‘x’ is called ‘prefix’ and y is called the suffix of w.
Example
Let’s consider w=’Theory’ is defined with prefix, x=’The’ and suffix , y=’ry’.
The substring is v=’o’, because, w=xvy and Theory= Thevry
Therefore, v=o
Kleen star operation
Let ‘w’ be a string. w’ is a set of strings obtained by applying any number of concatenations of w with itself, including empty string.
Example
a*= { ε,a,aa,aaa,………}
Reversal operation
If ‘w’ is a string, then wR is the reversal of the string in backwards.
Rules
The rules for the reversal operation are as follows −
- x=(xR)R
- (xz)R= zR.xR
Example
A string x is defined as x= tutorial then (xR)R is tutorial. This is because,
X= tutorial
(x)R= lairotut
(xR)R= tutorial
