Upcoming SlideShare
×

# String operation

270
-1

Published on

Data structure and Algorithm course material, CSC-391.

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total Views
270
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
20
0
Likes
1
Embeds 0
No embeds

No notes for slide

### String operation

1. 1. String Operation Csc-391
2. 2. 2 Data Structures and Algorithms Remarks • Each programming language contains a character set that is used to communicate with the computer. This set usually includes the followings- • Alphabet- A B C D… X Y Z • Digits- 0 1 2.. 9 • Special Characters- + - / * . (), {}, , \$ etc.. ©SMT, Faculty, CSE, IUBAT
3. 3. 3 Data Structures and Algorithms Storing String • For Example, ©SMT, Faculty, CSE, IUBAT
4. 4. 4 Data Structures and Algorithms Storing String • 1. Fixed- length storage. ©SMT, Faculty, CSE, IUBAT
5. 5. 5 Data Structures and Algorithms Storing String • 1. Fixed- length storage. ©SMT, Faculty, CSE, IUBAT
6. 6. 6 Data Structures and Algorithms Storing String • 2. Variable- length storage with fixed maximum. ©SMT, Faculty, CSE, IUBAT
7. 7. 7 Data Structures and Algorithms Storing String • 2. Variable- length storage with fixed maximum. ©SMT, Faculty, CSE, IUBAT
8. 8. 8 Data Structures and Algorithms Storing String • 3. Linked storage ©SMT, Faculty, CSE, IUBAT
9. 9. 9 Data Structures and Algorithms String Operation • Length: LENGTH (string) e.g.- LENGTH(‘Mark Zuckerberg’)= 15 • Substring: SUBSTRING(string, initial, length) e.g.- SUBSTRING(‘Impossible is a word found in coward’s dictionary’,0,20) = Impossible is a word • Indexing: INDEX(string, pattern) e.g.- INDEX(‘He is wearing glasses’, ‘ear’)= 8 • Concatenation: String1//String2 e.g.- ‘To be or not to be’// ‘, this is the question.’= To be or not to be, this is the question ©SMT, Faculty, CSE, IUBAT
10. 10. ©SMT, Faculty, CSE, IUBAT String Operation • Word Processing- Insertion: INSERT(string, position, string) e.g.- INSERT(‘ABCDEIJKL’,5,‘FGH’)= ABCDEFGHIJKL Deletion: DELETE(string, position, length) e.g.- DELETE(‘ABCDEFG’, 4, 2)= ABCDG
11. 11. 11 Data Structures and Algorithms String Operation – Replacement: REPLACE(string, pattern1, pattern2) e.g.- REPLACE(‘XABYABZ’, ‘AB’, ‘c’)= XCYABZ REPLACE function can be executed be using the following three steps- 1. K:= INDEX(string, P1) 2. T:= DELETE(string, K, LENGTH(P1)) 3. INSERT(T, K, P1) – So, the algorithm is- ©SMT, Faculty, CSE, IUBAT
12. 12. 12 Data Structures and Algorithms String Operation – Pattern Matching: Pattern matching is the problem of deciding whether or not a given string pattern P appears in a text. Widely used in word processing. – So, a basic algorithm is- ©SMT, Faculty, CSE, IUBAT
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.