The Wayback Machine - https://web.archive.org/web/20240822105435/https://www.geeksforgeeks.org/introduction-to-strings-data-structure-and-algorithm-tutorials/
Open In App

Introduction to Strings – Data Structure and Algorithm Tutorials

Last Updated : 31 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow
Show Topics
Solve Problem
Basic
59.12%
31.8K

What is String?

Strings are considered a data type in general and are typically represented as arrays of bytes (or words) that store a sequence of characters. Strings are defined as an array of characters. The difference between a character array and a string is the string is terminated with a special character ‘\0’

Complete Guide to String interview preparation

Complete Guide to String interview preparation

Below are some examples of strings:

“geeks” , “for”, “geeks”, “GeeksforGeeks”, “Geeks for Geeks”, “123Geeks”, “@123 Geeks”

How String is represented in Memory?

In C, a string can be referred to either using a character pointer or as a character array. When strings are declared as character arrays, they are stored like other types of arrays in C. For example, if str[] is an auto variable then the string is stored in the stack segment, if it’s a global or static variable then stored in the data segment, etc.

Representation of String

Representation of String

How to Declare Strings in various languages?

Below is the representation of strings in various languages:

C++
// C++ program to demonstrate String
// using Standard String representation

#include <iostream>
#include <string>
using namespace std;

int main()
{

    // Declare and initialize the string
    string str1 = "Welcome to GeeksforGeeks!";

    // Initialization by raw string
    string str2("A Computer Science Portal");

    // Print string
    cout << str1 << endl << str2;

    return 0;
}
C
// C program to illustrate strings
#include <stdio.h>

int main()
{
    // declare and initialize string
    char str[] = "Geeks";

    // print string
    printf("%s", str);

    return 0;
}
Java
// Java code to illustrate String
import java.io.*;
import java.lang.*;

class Test {
    public static void main(String[] args)
    {
        // Declare String without using new operator
        String s = "GeeksforGeeks";

        // Prints the String.
        System.out.println("String s = " + s);

        // Declare String using new operator
        String s1 = new String("GeeksforGeeks");

        // Prints the String.
        System.out.println("String s1 = " + s1);
    }
}
Python
# Python Program for
# Creation of String

# Creating a String
# with single Quotes
String1 = 'Welcome to the Geeks World'
print("String with the use of Single Quotes: ")
print(String1)

# Creating a String
# with double Quotes
String1 = "I'm a Geek"
print("\nString with the use of Double Quotes: ")
print(String1)

# Creating a String
# with triple Quotes
String1 = '''I'm a Geek and I live in a world of "Geeks"'''
print("\nString with the use of Triple Quotes: ")
print(String1)

# Creating String with triple
# Quotes allows multiple lines
String1 = '''Geeks
            For
            Life'''
print("\nCreating a multiline String: ")
print(String1)
C#
// Include namespace system
using System;

public class Test
{
    public static void Main(String[] args)
    {
        // Declare String without using new operator
        var s = "GeeksforGeeks";
        // Prints the String.
        Console.WriteLine("String s = " + s);
        // Declare String using new operator
        var s1 = new  String("GeeksforGeeks");
        // Prints the String.
        Console.WriteLine("String s1 = " + s1);
    }
}
JavaScript
<!DOCTYPE html>
<html>

<head>
    <title>
        JavaScript Strings
    </title>
</head>

<body>
    
    <h1>GeeksforGeeks</h1>
    
    <h2>JavaScript Strings</h2>
    
    <p id="GFG"></p>


    
    <!-- Script to store string in variable -->
    <script>
    
        // String written inside quotes
        var x = "Welcome to GeeksforGeeks!";
        document.getElementById("GFG").innerHTML = x;
    </script>
</body>

</html>
PHP
<?php

// single-quote strings

$site = 'Welcome to GeeksforGeeks';

echo $site;

?>

General Operations performed on String:

Here we are providing you with some must-know concepts of string:

1. Concatenation of Strings

The process of combining more than one string together is known as Concatenation. String Concatenation is the technique of combining two strings. 

Concatenation of Strings

Concatenation of Strings

There are two ways to concatenate two strings:

a) String concatenation without using any inbuilt methods:

Below is the algorithm for the Concatenation of two strings:

Algorithm: CONCATENATE (STR1, STR2, STR3)

1. LEN1 = LENGTH(STR1).
2. LEN2 = LENGTH(STR2).
3. SET I = 0.
4. Repeat Steps 5 and 6 while I < LEN1-1:
5. STR3[I] = STR1[I].
6. SET I = I+1.
7. SET J = 0.
8. Repeat Steps 9 to 11 while I < (LEN1 + LEN2 - 2):
9. STR3[I] = STR2[J].
10. J = J+1.
11. I = I+1.
12.Exit.

b) String concatenation using inbuilt methods:

2. Find in String

A very basic operation performed on Strings is to find something in the given whole string. Now, this can be to find a given character in a string, or to find a complete string in another string.

Find in String

Find in String

a) Find a character in string:

Given a string and a character, your task is to find the first position of the character in the string. These types of problems are very competitive programming where you need to locate the position of the character in a string.

b) Find a substring in another string:

Consider there to be a string of length N and a substring of length M. Then run a nested loop, where the outer loop runs from 0 to (N-M) and the inner loop from 0 to M. For every index check if the sub-string traversed by the inner loop is the given sub-string or not. 

An efficient solution is to use a O(n) searching algorithm like KMP algorithm, Z algorithm, etc.

Language implementations: 

3. Replace in String

Many times, it is very important to make corrections in strings. Replacing a character, word or phrase in a String is another very common operation performed on Strings.

The simplest approach to solve the given problem is to traverse the string S and when any string S1 is found as a substring in the string S then replace it by S2. Follow the steps below to solve this problem:

  • Initialize a string ans to store the resultant string after replacing all the occurrences of the substring S1 to S2 in the string S.
  • Iterate over the characters of the string S using variable i and perform the following steps:
    • If the prefix substring of the string S is equal to S1 from the index i, then add the string S2 in the string ans.
    • Otherwise, add the current character to the string ans.
  • After completing the above steps, print the string ans as the result.

4. Finding the Length of String

One of the most general operations on String is to find the length/size of a given string. Length is defined as the number of characters in a string is called the length of that string.

Finding the Length of String

Finding the Length of String

There are two ways to concatenate two strings:

a) Length of string without using any inbuilt methods: 

Below is the algorithm for finding the length of two strings:

1. SET LEN = 0 AND I = 0.
2. Repeat Steps 3 to 4 while STRING[I] is not NULL:
3. LEN = LEN + 1.
4. SET I = I + 1.
5. Exit.

b) Length of string using inbuilt methods:

5. Trim a String

Spaces or special characters are very common in Strings. So it is important to know how to trim such characters in String.

Below is a Simple Solution 

1) Iterate through all characters of given string, do following
   a) If current character is a space, then move all subsequent characters one position back and decrease length of the result string.

The time complexity of the above solution is O(n2).

A Better Solution can solve it in O(n) time. The idea is to keep track of count of non-space character seen so far. 

1) Initialize ‘count’ = 0 (Count of non-space character seen so far)
2) Iterate through all characters of given string, do following
     a) If current character is non-space, then put this character at index ‘count’ and increment ‘count’
3) Finally, put ‘\0’ at index ‘count’

6. Reverse and Rotation of a String

Reverse operation is interchanging the position of characters of a string such that the first becomes the last, the second becomes the second last, and so on.

a) Rotations of a String:

Rotation of a String

Rotation of a String

Consider a string “geeks”, now all possible rotations for this will be:

  • geeks
  • eeksg
  • eksge
  • ksgee
  • sgeek

b) Reverse a String:

The reversing of a string is nothing but simply substituting the last element of a string to the 1st position of the string.

Reverse a String

7. Subsequence of a String

A subsequence is a sequence that can be derived from another sequence by removing zero or more elements, without changing the order of the remaining elements.

More generally, we can say that for a sequence of size n, we can have (2n-1) non-empty sub-sequences in total.

For example, Consider the string “geeks”, there are 15 sub-sequences. 
They are:

g, e, e, k, s,
ge, ge, gk, gs, ee, ek, es, ek, es, ks,
gee, gek, ges, gek, ges, gks, eek, ees, eks, eks,
geek, gees, eeks,
geeks

Subsequence

8. Substring of a String

A substring is a contiguous part of a string, i.e., a string inside another string.

In general, for a string of size n, there are n*(n+1)/2 non-empty substrings.

For example, Consider the string “geeks”, There are 15 non-empty substrings.
The subarrays are:

g, ge, gee, geek, geeks,
e, ee, eek, eeks,
e, ek, eks,
k, ks,
ks

Substring

9. Binary String

A Binary String is a special kind of string made up of only two types of characters, such as 0 and 1.
For Example:  

Input: str = "01010101010"
Output: Yes, it is a Binary String
Input: str = "geeks101"
Output: No, it is not a Binary String

10. Palindrome String

A string is said to be a palindrome if the reverse of the string is the same as the string. 
For example,

“abba” is a palindrome, but “abbc” is not a palindrome.

Palindrome String

11. Lexicographic Patterns

Lexicographical pattern is the pattern based on the ASCII value or can be said in dictionary order. We consider the lexicographic order of characters as their order of ASCII value. Hence the lexicographical order of characters will be 

‘A’, ‘B’, ‘C’, …, ‘Y’, ‘Z’, ‘a’, ‘b’, ‘c’, …, ‘y’, ‘z’.

12. Pattern Searching

Pattern searching is searching a given pattern in the string. It is an advanced topic of string. The Pattern Searching algorithms are sometimes also referred to as String Searching Algorithms and are considered as a part of the String algorithms. These algorithms are useful in the case of searching a string within another string.

Pattern Searching

Pattern Searching

Top Theoretical Interview Questions

S.noQuestionAnswer
1What are different ways to create String Object?View
2Can we compare String using the == operator? What is the risk?View
3How to replace a substring with ( from a string ?View
4What is the difference between String and StringBuffer in java?View
5How do I convert a string version of a number in an arbitrary base to an integer?View
6How do you compare two Strings in Java?View
7What is String in Data Structures?  View
8What is the difference between Strings vs. Char arrays?  View
9What is a null-terminated String?  View
10 Reverse a String using StackView
11Difference between String, StringBuffer and StringBuilder?View
12Why String is immutable or final in JavaView
13What Is the String Constant Pool?View
14Remove Invalid ParenthesesView
15What is the use of the substring() method?View
16Explain how can I remove the trailing spaces from a StringView
17Explain how can I pad a string to known lengthView
18Explain how can you tell whether two string are the sameView
19How to check if the String is empty?View
20Can we use a string in the switch case in java?View
21How string concatenation using the + operator works in Java?View
22What are the different string methods in Java?View
23What do you mean by StringJoiner?View
24How to convert string representation of list to a list?View
26How do I tokenize a string in C++?View
27Print all permutations of the String ?View
28How do you reverse a given string in place? View
29How to convert a byte array to String?View
30How to calculate total number of vowels in String?View
31Write a program to convert a string in lowercaseView
32Write a program to convert a string in uppercase.View
33Write a C++ program to find the length of the string.View
34In what way should two whether they are anagrams?strings be compared to determine View
35Write a java program to tOGGLE each word in string?View
36How to convert String to Date in java?View
37Java Program to reverse a given String with preserving the position of spaceView
38Multiply Large Numbers represented as StringsView
39String “indexOf” MethodView

Top 50 interview coding question

Easy Problems on String

S.noQuestionPractice
1Reverse words in a given stringLink
2Longest Common PrefixLink
3Roman Number to IntegerLink
4Integer to RomanLink
5Closest StringsLink
6Divisible by 7Link
7Encrypt the String – IILink
8Equal point in a string of bracketsLink
9Isomorphic StringsLink
10Check if two strings are k-anagrams or notLink
11Panagram CheckingLink
12Check if string is rotated by two placesLink

 

Medium Problems on String

S.noQuestionPractice
1Minimum DeletionsLink
2Number of Distinct SubsequencesLink
3Implement AtoiLink
4Validate an IP addressLink
5License Key FormattingLink
6Find largest word in dictionaryLink
7Equal 0,1, and 2Link
8Find and replace in StringLink
9Add Binary StringsLink
10Sum of two large numbersLink
11Multiply two stringsLink
12Look and say PatternLink
13Minimum times A has to be repeated to make B a SubstringLink
14Excel Sheet – ILink
15Form a PalindromeLink
16Find the N-th characterLink
17Next higher palindromic numbers using the same set of digitsLink
18Length of longest prefix suffixLink
19Longest K unique characters substringLink
20Smallest window in a string containing all charactersLink
21Longest Palindromic SubsequenceLink
22Longest substring without repeating charactersLink
23Substrings of length k with k-1 distinct elementsLink
24Count number of substringsLink
25Interleaved StringsLink
26Print Anagrams togetherLink
27Rank the permutationLink
28A Special KeyboardLink

 

Hard Problems on String

S.noQuestionPractice
1Restrictive Candy CrushLink
2Edit DistanceLink
3Search Pattern (KMP-Algorithm)Link
4Search Pattern (Rabin-Karp Algorithm)Link
5Search Pattern (Z-algorithm)Link
6Shortest Common SupersequenceLink
7Number of words with K maximum distinct vowelsLink
8Longest substring to form a PalindromeLink
9Longest Valid ParenthesisLink
10Distinct Palindromic SubstringsLink

Advantages of using String:

  • Versatility: Strings can store and manipulate text data, making them useful for a wide range of applications and programming tasks.
  • Readability: Strings allow for clear representation and interpretation of human-readable text, making code easier to understand and maintain.
  • Ease of Use: String manipulation operations, such as concatenation, searching, and replacement, are typically straightforward and supported by many programming languages.
  • Text Processing: Strings provide efficient operations for searching, matching, and manipulating patterns in text, which is valuable for tasks such as parsing, data extraction, and text analysis.

Disadvantages of String:

  • Strings are generally slow in performing operations like input, output.
  • In JAVA strings are  immutable they cannot be modified or changed
  • 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.

Application of String:

  • Text Processing: Strings are extensively used for text processing tasks such as searching, manipulating, and analyzing textual data.
  • Data Representation: Strings are fundamental for representing and manipulating data in formats like JSON, XML, and CSV.
  • Encryption and Hashing: Strings are commonly used in encryption and hashing algorithms to secure sensitive data and ensure data integrity.
  • Database Operations: Strings are essential for working with databases, including storing and querying text-based data.
  • Web Development: Strings are utilized in web development for constructing URLs, handling form data, processing input from web forms, and generating dynamic content.

IMPORTANT’S POINTS:

  • Strings are immutable in many programming languages.

Frequently asked questions (FAQs) on String

1. Is string a linear data structure?

Yes, string is a linear data structure.

2. Where are strings used?

It is used to store the sequence of characters.

3. Is string a data type?

A string is generally considered a data type and is often implemented as an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding.

4. Why is text called string?

Text are also called string because it consists of sequence of characters like string.

5. What are characters in a string?

Each digit in a string is a character and character is a single visual object used to represent text, numbers, or symbols.

Conclusion

After the discussion, we concluded that Strings are a simple method to store some textual information and Strings are an array of characters that terminate with a null character ‘\0’. The difference between a character array and a string is that, unlike the character array, the string ends with a null character. Apart from this we have also discussed Top theoretical interview questions as well as Top 50 interview coding question on string which will help you to tackle interview problems.

Related articles:



Previous Article
Next Article

Similar Reads

Static Data Structure vs Dynamic Data Structure
Data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed be efficient with respect to time as well as memory. Simply, Data Structure are used to reduce complexity (mostly the time complexity) of the code. Data structures can be two types : 1. Static Data Structure 2. Dynamic Data
4 min read
Introduction to the Probabilistic Data Structure
Introduction: Probabilistic Data Structures are data structures that provide approximate answers to queries about a large dataset, rather than exact answers. These data structures are designed to handle large amounts of data in real-time, by making trade-offs between accuracy and time and space efficiency. Some common examples of Probabilistic Data
5 min read
Introduction to Universal Hashing in Data Structure
Universal hashing is a technique used in computer science and information theory for designing hash functions. It is a family of hash functions that can be efficiently computed by using a randomly selected hash function from a set of hash functions. The goal of universal hashing is to minimize the chance of collisions between distinct keys, which c
5 min read
Introduction to Hierarchical Data Structure
We have discussed Overview of Array, Linked List, Queue and Stack. In this article following Data Structures are discussed. 5. Binary Tree 6. Binary Search Tree 7. Binary Heap 8. Hashing Binary Tree Unlike Arrays, Linked Lists, Stack, and queues, which are linear data structures, trees are hierarchical data structures. A binary tree is a tree data
13 min read
Introduction to Augmented Data Structure
Data Structures play a significant role in building software and applications but many a times all our requirements are not satisfied using an existing data structure. This is when we modify an existing data structure according to our needs. This article will provide a brief introduction about when and how to Augment a Data Structure. Table of Cont
10 min read
Introduction to Splay tree data structure
Splay tree is a self-adjusting binary search tree data structure, which means that the tree structure is adjusted dynamically based on the accessed or inserted elements. In other words, the tree automatically reorganizes itself so that frequently accessed or inserted elements become closer to the root node. The splay tree was first introduced by Da
15+ min read
Introduction to Finger search tree Data Structure
A finger search tree is a data structure that is designed to allow for efficient search and access of data in a set or a sequence. It is a type of binary search tree that uses a "finger" or a reference to a particular element in the tree to quickly find and retrieve other elements. In this article, we will explore the types, advantages, disadvantag
15+ min read
Introduction to Min-Heap Data Structure
A Min-Heap is defined as a type of Heap Data Structure in which each node is smaller than or equal to its children.  The heap data structure is a type of binary tree that is commonly used in computer science for various purposes, including sorting, searching, and organizing data. Purpose and Use Cases of Min-Heap: Implementing Priority Queue: One o
15+ min read
Introduction to Tree Data Structure
Tree data structure is a specialized data structure to store data in hierarchical manner. It is used to organize and store data in the computer to be used more effectively. It consists of a central node, structural nodes, and sub-nodes, which are connected via edges. We can also say that tree data structure has roots, branches, and leaves connected
15+ min read
Introduction to Graph Data Structure
Graph Data Structure is a non-linear data structure consisting of vertices and edges. It is useful in fields such as social network analysis, recommendation systems, and computer networks. In the field of sports data science, graph data structure can be used to analyze and understand the dynamics of team performance and player interactions on the f
15+ min read
Introduction to Matrix or Grid Data Structure - Two Dimensional Array
Matrix or Grid is a two-dimensional array mostly used in mathematical and scientific calculations. It is also considered as an array of arrays, where array at each index has the same size. In this article, we will cover all the basics of Matrix, the Operations on Matrix, its implementation, advantages, disadvantages which will help you solve all th
14 min read
Data Structure Alignment : How data is arranged and accessed in Computer Memory?
Data structure alignment is the way data is arranged and accessed in computer memory. Data alignment and Data structure padding are two different issues but are related to each other and together known as Data Structure alignment. Data alignment: Data alignment means putting the data in memory at an address equal to some multiple of the word size.
4 min read
Difference between data type and data structure
Data Type A data type is the most basic and the most common classification of data. It is this through which the compiler gets to know the form or the type of information that will be used throughout the code. So basically data type is a type of information transmitted between the programmer and the compiler where the programmer informs the compile
4 min read
Difference between Greedy Algorithm and Divide and Conquer Algorithm
Greedy algorithm and divide and conquer algorithm are two common algorithmic paradigms used to solve problems. The main difference between them lies in their approach to solving problems. Greedy Algorithm:The greedy algorithm is an algorithmic paradigm that follows the problem-solving heuristic of making the locally optimal choice at each stage wit
3 min read
Is array a Data Type or Data Structure?
What is Data Type? In computer programming, a data type is a classification of data that determines the type of values that can be stored, manipulated, and processed. It tells the computer what kind of data a particular variable or constant can hold, and what operations can be performed on that data. Common data types include integers, floating-poi
8 min read
Edge Relaxation Property for Dijkstra’s Algorithm and Bellman Ford's Algorithm
In the field of graph theory, various shortest path algorithms especially Dijkstra’s algorithm and Bellmann-Ford’s algorithm repeatedly employ the use of the technique called Edge Relaxation. The idea of relaxation is the same in both algorithms and it is by understanding, the 'Relaxation property' we can fully grasp the working of the two algorith
4 min read
Difference Between Dijkstra's Algorithm and A* Search Algorithm
Dijkstra's Algorithm and A* Algorithm are two of the most widely used techniques. Both are employed to the find the shortest path between the nodes in a graph but they have distinct differences in their approaches and applications. Understanding these differences is crucial for the selecting the appropriate algorithm for the given problem. What is
3 min read
Karatsuba algorithm for fast multiplication using Divide and Conquer algorithm
Given two binary strings that represent value of two integers, find the product of two strings. For example, if the first bit string is "1100" and second bit string is "1010", output should be 120. For simplicity, let the length of two strings be same and be n. A Naive Approach is to follow the process we study in school. One by one take all bits o
15+ min read
Introduction to Exact Cover Problem and Algorithm X
If you have ever tried to create a program for solving Sudoku, you might have come across the Exact Cover problem. In this article, we will discuss what is the exact cover problem and an algorithm “Algorithm X” proposed by Donald Knuth to solve this problem. Given a collection S of subsets of set X, an exact cover is the subset S* of S such that ea
6 min read
Introduction and implementation of Karger's algorithm for Minimum Cut
Given an undirected and unweighted graph, find the smallest cut (smallest number of edges that disconnects the graph into two components). The input graph may have parallel edges. For example consider the following example, the smallest cut has 2 edges. A Simple Solution use Max-Flow based s-t cut algorithm to find minimum cut. Consider every pair
15+ min read
Algorithm Library | C++ Magicians STL Algorithm
For all those who aspire to excel in competitive programming, only having a knowledge about containers of STL is of less use till one is not aware what all STL has to offer. STL has an ocean of algorithms, for all &lt; algorithm &gt; library functions : Refer here.Some of the most used algorithms on vectors and most useful one's in Competitive Prog
7 min read
What is the stupidest sorting algorithm? (Worst Sorting Algorithm)
Bogo sort stands out as the undisputed champion of stupidity. Unlike other sorting algorithms that follow a structured approach, Bogo sort relies on sheer luck and randomness to achieve its goal. How Bogo Sort Works?Bogo sort operates on the following principle: Randomly shuffle the elements in the list.Check if the list is sorted.If the list is no
2 min read
Z algorithm (Linear time pattern searching Algorithm)
This algorithm efficiently locates all instances of a specific pattern within a text in linear time. If the length of the text is "n" and the length of the pattern is "m," then the total time taken is O(m + n), with a linear auxiliary space. It is worth noting that the time and auxiliary space of this algorithm is the same as the KMP algorithm, but
13 min read
Find count of Alphabetic and Alphanumeric strings from given Array of Strings
Given an array of strings arr[] of size N. Each of the strings contains lowercase English letters or numbers only. The task is to find the frequency of alphabetic and alphanumeric strings in the array. Note: If any string has atleast one number in it, the string is an alphanumeric string. Examples: Input: arr[] = {"abcd", "mak87s", "abcd", "kakjdj"
7 min read
Test Case Generation | Set 2 ( Random Characters, Strings and Arrays of Random Strings)
Set 1 (Random Numbers, Arrays and Matrices) Generating Random Characters C/C++ Code // A C++ Program to generate test cases for // random characters #include&lt;bits/stdc++.h&gt; using namespace std; // Define the number of runs for the test data // generated #define RUN 5 // Define the range of the test data generated // Here it is 'a' to 'z' #def
11 min read
Karatsuba Algorithm for fast Multiplication of Large Decimal Numbers represented as Strings
Given two numeric strings A and B, the task is to find the product of the two numeric strings efficiently. Example: Input: A = 5678, B = 1234Output: 7006652 Input: A = 74638463789, B = 35284567382Output: 2633585904851937530398 Approach: The given problem can be solved using Karastuba's Algorithm for Fast Multiplication, the idea is to append zeroes
15+ min read
Introduction to Push Relabel Algorithm
Given a graph which represents a flow network where every edge has a capacity. Also given two vertices source ‘s’ and sink ‘t’ in the graph, find the maximum possible flow from s to t with following constraints: Flow on an edge doesn’t exceed the given capacity of the edge. Incoming flow is equal to outgoing flow for every vertex except s and t. Fo
6 min read
Hopcroft–Karp Algorithm for Maximum Matching | Set 1 (Introduction)
A matching in a Bipartite Graph is a set of the edges chosen in such a way that no two edges share an endpoint. A maximum matching is a matching of maximum size (maximum number of edges). In a maximum matching, if any edge is added to it, it is no longer a matching. There can be more than one maximum matching for a given Bipartite Graph. We have di
3 min read
Introduction of Hu-Tucker algorithm
Introduction of the Hu-Tucker algorithm :The Hu-Tucker algorithm helps to compress some order of blocks, assuming that you have a certain natural order for the following, then if the strings and the notes are taken into account, then taking them into account, they are sorted in numbers.The question now arises about how we can build the order so tha
5 min read
Introduction to Grover's Algorithm
Grover's algorithm is a quantum algorithm that solves the unstructured search problem. In an unstructured search problem, we are given a set of N elements and we want to find a single marked element. A classical computer would need to search through all N elements in order to find the marked element, which would take time O(N). Grover's algorithm,
7 min read
three90RightbarBannerImg