Topic 04
Topic 04
By
Engr. Mohammad Nawaz
Lecturer at CSE&S Department
Balochistan UET khuzdar
Data Structure & Algorithms
CLO-1(PLO-1) 2
Previous Lecture Review
• String Definition
• Memory Representation
• Operations of String
– Substring
– Indexing
– Length
– Concatenation
Formula
Insert = (text, position, string)
0 1 2 3 4 5 6 7 8 9
M A S T U D E N T \0
INSERT(M, 2, “GOOD□”)
THEN
M=”A GOOD STUDENT”
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
M A G O O D S T U D E N T \0
Data Structure & Algorithms
CLO-1(PLO-1) 11
2. Deletion
To delete or remove number of characters from string with
given position.
Formula
DELETE (string, position, length)
S A G O O D S T U D E N T \0
DELETE (S, 2, 5)
then
= (“A STUDENT”)
0 1 2 3 4 5 6 7 8 9
S A S T U D E N T \0
Data Structure & Algorithms
CLO-1(PLO-1) 13
3.Replacement
Replacing one string in the text by another.
Formula
Old Text
New Text