Different string operations....................

MeghaKulkarni27 110 views 11 slides Feb 23, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

strings


Slide Content

2 Data Structures and Algorithms R emar k s 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- 1 2.. 9 Special Characters- + - / * . (), {}, , $ etc..

3 Data Structures and Algorithms Storing String For Example,

4 Data Structures and Algorithms Storing String 1. Fixed- length storage.

5 Data Structures and Algorithms Storing String 1. Fixed- length storage.

6 Data Structures and Algorithms Storing String 2. Variable- length storage with fixed maximum.

7 Data Structures and Algorithms Storing String 2. Variable- length storage with fixed maximum.

8 Data Structures and Algorithms Storing String 3. Linked storage

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

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 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- K:= INDEX(string, P1) T:= DELETE(string, K, LENGTH(P1)) INSERT(T, K, P1) So, the algorithm is- ©SMT, Faculty, CSE, IUBAT

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
Tags