C++ Articles - Page 662 of 719

Case-insensitive string comparison in C++

Farhan Muhamed
Updated on 17-Apr-2025 19:24:48

9K+ Views

To compare two strings in C++, we can use various inbuilt functions and approaches that are already discussed in the previous sections. However, there are some cases where we need to compare two strings case-insensitively, meaning that we need to ignore the case of the characters in the strings while comparing them. In this article, we will focus on learning how to compare two strings case-insensitively in C++. Here is a list of approaches for case-insensitively string comparison, which we will be discussing in this article with stepwise explanation and complete example codes. ... Read More

C++ Program to Perform String Matching Using String Library

Farhan Muhamed
Updated on 26-May-2025 12:47:32

3K+ Views

The string library provides several functions to manipulate and match strings. In this article, we will see how the various functions of string library functions can be used to match strings in C++. String Matching in C++ String matching is a process of locating one string in another string. Meaning, here we will find the position of a string inside another string. The string matching functions will return the position of the first occurrence of the substring in the main string. If the substring is not found, it will return a special value such as -1 or string::npos. ... Read More

C++ Program to Implement Wagner and Fisher Algorithm for online String Matching

Farhan Muhamed
Updated on 22-May-2025 18:06:15

491 Views

Here, we will see how to use Wagner and Fisher algorithm for string matching in C++. Using this algorithm, we can find how many minimum changes are required to match those strings. Wagner Fisher Algorithm Wagner Fisher is a dynamic programming algorithm that is used to find the minimum edit distance or levenshtein distance between two input strings. Levenshtein distance between two strings means the number of changes (ie, insertion, deletion or updation) required to convert one string into another. In simpler words, this algorithm will calculate a minimum number of changes required to convert ... Read More

C/C++ Macro for string concatenation

Farhan Muhamed
Updated on 16-Apr-2025 19:01:53

5K+ Views

C++ provides multiple ways to concatenate strings. Macro string concatenation is one of such way. In this article, we will learn how to use C++ preprocessor macros to concatenate strings and tokens. Understanding Macros in C++ In C++, macros are small pieces of code that are defined using the preprocessor directive #define. Macros are generally used to define variables, constants, functions, and other code blocks. When the code is compiled, the preprocessor replaces every occurrence of the macro with its defined value before actual compilation begins. Let's see an example of a macro definition and its usage. // ... Read More

C++ Program to Check the Connectivity of Undirected Graph Using DFS

Jennifer Nicholas
Updated on 15-Apr-2025 18:12:55

4K+ Views

The Depth-First Search (DFS) is a graph traversal algorithm that starts at root node and explores as far as possible along each branch before moving to next branch. In this article, we will discuss how to check the connectivity of a graph using DFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then ... Read More

C++ Program to Check the Connectivity of Directed Graph Using BFS

Farhan Muhamed
Updated on 15-Apr-2025 18:14:46

833 Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a directed graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ... Read More

C++ Program to Check the Connectivity of Undirected Graph Using BFS

Vrundesha Joshi
Updated on 15-Apr-2025 12:55:54

1K+ Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ... Read More

C++ Program to Represent Graph Using Linked List

Farhan Muhamed
Updated on 15-Apr-2025 18:25:28

2K+ Views

What is Linked List? A linked list is a linear data structure which can store a collection of "nodes" connected together via links i.e. pointers. Linked lists nodes are not stored at a contiguous location, rather they are linked using pointers to the different memory locations. A linked list can be used for graph representations. In the graph representation: Each vertex has its own linked list that stores its adjacent vertices. This forms an adjacency list using linked lists instead of vectors or arrays. Graph The image below ... Read More

C++ Program to Represent Graph Using Adjacency List

Farhan Muhamed
Updated on 15-Apr-2025 18:23:30

4K+ Views

What is Adjacency List? An adjacency list is a collection of unordered lists that are used to represent a finite graph. Each list in the collection represents one of the vertex of the graph and it will store the adjacent vertices of that vertex. Let's see an example: Graph The image below represent a simple undirected graph with 6 vertices and 8 edges. Adjacency List The adjacency list of the above graph is shown below. Algorithm The following are the steps to create (represent) a graph using an adjacency list: ... Read More

C++ Program to Represent Graph Using Incidence Matrix

Farhan Muhamed
Updated on 15-Apr-2025 18:20:09

2K+ Views

What is incidence matrix? An incidence matrix is a mathematical representation of a graph that shows the relationship between vertices and edges. In other words, it is a matrix M of size v x e, where v = number of vertices and e = number of edges. For example, if the graph has an edge number n from vertex i to vertex j, then in the incidence matrix at ith row and nth column it will be 1. Graph The image below represent a simple undirected graph with 6 vertices and 8 edges. Incidence Matrix The incidence ... Read More

Advertisements