Found 7197 Articles for C++

B*-Trees implementation in C++

Raunak Jain
Updated on 16-Jan-2023 16:03:38

2K+ Views

B*-Trees: An Optimized Data Structure for Fast Data Retrieval in C++ A B*-tree is a self-balancing tree data structure that is optimized for fast data retrieval. It is a variant of the B-tree, which is a tree data structure that is designed to keep its data sorted and balanced. A B-tree is characterized by the fact that it has a high degree of order, meaning that its nodes are kept sorted in a specific manner. A B*-tree is similar to a B-tree, but it is optimized for even better performance. This is achieved through the use of a number of ... Read More

C++ Program To Find the Trace and Normal of a given Matrix

Arnab Chakraborty
Updated on 14-Dec-2022 15:09:38

1K+ Views

Several applications greatly benefit from the use of 2-dimensional arrays or matrices. Numbers are stored in rows and columns of matrices. Using multi-dimensional arrays, we may define 2D matrices in C++ as well. In this post, we'll look at how to use C++ to determine the Normal and Trace of a given matrix. The square root of the total number of elements in the matrix is what is known as the Normal. The trace is made up of all the components that make up the main diagonal. Let's look at the representation of the algorithm in C++ code. Matrix Trace ... Read More

C++ Program to Compute the Sum of Diagonals of a Matrix

Arnab Chakraborty
Updated on 14-Dec-2022 16:04:28

7K+ Views

The utilization of 2-dimensional arrays or matrices is extremely advantageous for several applications. Matrix rows and columns are used to hold numbers. We can define 2D matrices in C++ using multi-dimensional arrays as well. In this article, we'll look at how to use C++ to calculate the diagonal sum of a given square matrix. The matrices have two diagonals, the main diagonal and the secondary diagonal (sometimes referred to as major and minor diagonals). The major diagonal starts from the top-left corner (index [0, 0]) to the bottom-right corner (index [n-1, n-1]) where n is the order of the square ... Read More

C++ Program to Compare two strings lexicographically

Arnab Chakraborty
Updated on 02-Dec-2024 00:22:48

10K+ Views

Lexicographic string comparison states the strings are compared in dictionary order. For example, if two strings ‘apple’ and ‘appeal’ are there, the first string will come next because the first three characters ‘app’ are the same. Then for the first string, the character is ‘l’ and in the second string, the 4th character is ‘e’. Since ‘e’ is shorter than ‘l’, it will come first if we arrange them in lexicographic order. Before arranging, the strings are compared lexicographically. In this article, we will see different techniques to compare two strings in a lexicographic manner using C++. Using compare() functions ... Read More

C++ Program to Print first letter of each word using regex

Arnab Chakraborty
Updated on 14-Dec-2022 14:45:07

490 Views

A useful tool for string operations is regex. This may be found in virtually all high-level current programming languages, including C++. Regular expressions (Regex) are utilized as general-purpose search patterns. For instance, by constructing a straightforward string known as a regular expression, we may implement password validation logic with at least one capital, one lowercase, one number, one special character, and a total length of at least 8 characters. In this tutorial, we'll look at how to use C++ to display only the first letters of words included within a specified string. Here, we'll look at a sentence that uses ... Read More

C++ Program to Swapping Pair of Characters

Arnab Chakraborty
Updated on 14-Dec-2022 14:39:09

3K+ Views

A string is a group of characters. They can be described as character arrays as well. An array of characters can be thought of as strings, and each string has a set of indices and values. The switching of characters at two specified indices in a string is one of the modifications we can sometimes make to strings. In this article, we will see how to swap two characters in a string from two given indices using C++. Syntax char temp = String_variable[ ] String_variable[ ] = String_variable[ ] String_variable[ ] = temp Using indices, ... Read More

C++ Program to Replace a Character at a Specific Index

Arnab Chakraborty
Updated on 14-Dec-2022 14:37:16

2K+ Views

Strings are a collection of characters. We can also say them as character arrays. Considering an array of characters as strings, the strings have specified indices and values. Sometimes we can perform some modification on strings, one such modification is replacing characters by providing a specific index. In this article, we will see how to replace a character from a specific index inside a string using C++. Syntax String_variable[ ] = In C++ we can access the string characters using indices. Here to replace a character with some other character at a specified index, we simply ... Read More

C++ Program to Iterate Over an Array

Arnab Chakraborty
Updated on 14-Dec-2022 14:34:45

4K+ Views

Arrays are data of the same type stored in contiguous locations in memory. To access or address an array, we use the starting address of the array. Arrays have indexing, using which we can access the elements of the array. In this article, we take a look at methods to iterate over an array. This means accessing the elements that are present in an array. Using for loop The most common method of iterating over an array is using for loops. We use a for loop to iterate through an array in the next example. One thing is to be ... Read More

C++ Program to Find the Normal and Trace

Arnab Chakraborty
Updated on 14-Dec-2022 14:50:37

426 Views

2-Dimensional arrays or matrices are very much useful in several applications. Matrices have rows and columns and store numbers inside them. In C++ also we can define 2D matrices using multi-dimensional arrays. In this article, we will see how to calculate the Normal and the Trace of a given matrix using C++. The Normal is the square root of the sum of all elements present in the matrix. And the trace is the sum of elements present in the main diagonal. Let us see the algorithm and C++ code representation. Matrix Normal $\begin{bmatrix} 5 & 1& 8ewline 4 ... Read More

C++ Program to Copy All the Elements of One Array to Another Array

Arnab Chakraborty
Updated on 14-Dec-2022 12:22:48

4K+ Views

The array data structures are used to store homogeneous data in a consecutive memory location to access them in a sequential manner. Arrays are linear data structure so that the basic operations on array can be performed in linear time. In this article we will see how to copy elements from one array to another new array in C++. The new array will be of same type since array elements are homogeneous. After creating another array of same size, we simply copy the elements from first array to the second one by one. Let us see the algorithm and the ... Read More

Advertisements