Skip to content
Related Articles

Related Articles

Applications, Advantages and Disadvantages of String

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 25 May, 2022
View Discussion
Improve Article
Save Article

String is a data structure that is similar to the array data structure in terms of representation, and implementation but in strings, we store a sequence of characters (char data type) which includes alphabets, numbers, spaces and other special characters.

String Representation

String Representation

  Applications of String:

  • Plagiarism Checker: Strings can be used to find Plagiarism in codes, and contents in a very little amount of time using string matching algorithms. Using this the computer could easily tell us the percentage of code, and text written by any two users matches by how much percent.
  • Encoding/Decoding(Cipher Text Generation): Strings can be used for encoding and decoding for the safe transfer of data from sender to receiver to make sure no one in the way of transmission gets to read your data as they could perform both active and passive attacks. The text you transfer as a message gets ciphered at the sender’s end and decoded at the receiver’s end.
  • Information Retrieval: String applications help us to retrieve information from unknown data sources( large datasets used as input) along with the help of string matching/retrieval module helps us to retrieve important information.
  • Improved Filters For The Approximate Suffix-Prefix Overlap Problem: Strings and its algorithms applications help us to provide improved Filters for the Approximate Suffix-Prefix Overlap Problem. The approximate suffix-prefix overlap problem is to find all pairs of strings from a given set such that a prefix of one string is similar to a suffix of the other.

Real-Time Application of String:

  • Spam Detection: Strings can be used to serve as a spam detection system as the concept of string matching algorithm will be applied here. Spam (unwanted emails) could cause great financial loss. All the spam filters use the concept of string matching to identify and discard the spam.
  • Bioinformatics: Strings can be used in the field of Bioinformatics( DNA sequencing). String matching module can be used to solve issues or problems regarding genetic sequences and to find the patterns in DNA.
  • Intrusion Detection System: Strings can be used in intrusion detection systems. Packets that contain intrusion related keywords are found by applying string matching algorithms.
  • Search Engines: Strings can be used in many search engine techniques. Most of the data are available on the internet in the form of textual data. Due to huge amount of uncategorized text data, it becomes really difficult to search a particular content. Web search engines organize the data and to categorize the data string matching algorithms are used.

   Operations on String:

String provides users with various operations. Some of the important ones are:

  • size(): This function is used to find the length of the string.
  • substr(): This is used to find a substring of length a particular length starting from a particular index.
  • +: This operator is used to concatenate two strings.
  • s1.compare(s2): This is used to compare two strings s1 and s2 to find which is lexicographically greater and which one is smaller.
  • reverse(): This function is used to reverse a given string. 
  • sort(): This function is used to sort the string in lexicographic order. 

For more reference to operations on string refer to: C/C++ Operations On String

Advantages of String:

  • String provides us a string library to create string objects which will allow strings to be dynamically allocated and also boundary issues are handled inside class library.
  • String provides us various inbuilt functions under string library such as sort(), substr(i, j), compare(), push_back() and many more.
  • In C language strings can have compile-time allocation and determination of size. This makes them more efficient, faster run-time at the time of using them.
  • In C++ we do not need to predefine the size of a string.
  • String helps as a base for many data structures such as tries, suffix trees, suffix arrays, ternary search trees, and much more.
  • Strings provide us very helpful string algorithms for solving very complex problems with less time complexity.

    Disadvantages of String:

  • In JAVA strings are  immutable they cannot be modified or changed
  • Strings are generally slow in performing operations like input, output.
  • In JAVA you cannot extend string class which means overriding methods in string class is not possible.
  • C strings are fixed in size and are not dynamic.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!