Found 1234 Articles for Data Structure

Sum of frequencies of characters of a string present in another string

Siva Sai
Updated on 18-May-2023 14:12:10
In this article, we are going to explore an interesting problem related to string manipulation in C++. The problem statement is "Sum of frequencies of characters of a string present in another string". This problem provides a great opportunity to enhance your understanding of string operations, character frequency calculation, and the concept of mapping in C++. Problem Statement Given two strings, the task is to find the sum of frequencies of characters of the first string that are present in the second string. C++ Solution Approach To solve this problem, we will first create frequency maps for both strings using ... Read More

string__npos in C++ with Examples

Siva Sai
Updated on 18-May-2023 14:10:08
In this article, we will delve into a specific aspect of string handling in C++: the string::npos constant. string::npos is a static member constant value with the greatest possible value for an element of type size_t. This constant is defined with a value of -1, which, when cast to size_t, gives us the largest possible representation for size_t. In the context of strings in C++, it is generally used to indicate an invalid position. What is String::npos? In C++, string::npos is a constant static member of the std::string class that represents the maximum possible value for the size_t type. It ... Read More

Sort an array of strings in ascending order with each string sorted in descending order

Siva Sai
Updated on 18-May-2023 14:07:45
In this article, we dive into a unique and interesting problem related to arrays and string manipulation in C++. The problem at hand is "Sort an array of strings in ascending order with each string sorted in descending order". This problem is an excellent way to enhance your knowledge of string manipulation, arrays, and sorting algorithms. Problem Statement Given an array of strings, the task is to sort the array in ascending order, but with each string sorted in descending order. C++ Solution Approach We can solve this problem by using the sort function provided by the C++ Standard Library. ... Read More

Remove all occurrences of a word from a given string using Z-algorithm

Siva Sai
Updated on 18-May-2023 14:05:54
This article delves into an interesting string manipulation problem: "Remove all occurrences of a word from a given string using Z-algorithm". This problem serves as an excellent use case for the Z-algorithm, highlighting its efficacy in pattern searching problems. Let's explore in detail. Problem Statement Given a string S and a word W, the task is to remove all occurrences of W from S using the Z-algorithm. Understanding the Problem Consider a string S = "HelloWorldHelloWorld" and a word W = "World". The goal is to remove all occurrences of W from S. Hence, the output would be "HelloHello". Z-algorithm ... Read More

Rearrange a string to maximize the minimum distance between any pair of vowels

Siva Sai
Updated on 18-May-2023 14:03:49
In this article, we're going to unravel an interesting problem from the domain of string manipulation: "Rearrange a string to maximize the minimum distance between any pair of vowels". This problem challenges us to manipulate the arrangement of characters in a string to ensure the maximum possible minimum distance between any two vowel characters. We'll discuss the problem in detail, provide a C++ code implementation, and illustrate with an example. Understanding the Problem Statement Given a string, the task is to rearrange the characters in the string in such a way that the minimum distance between any pair of vowels ... Read More

Other Primary File Organizations

Mithlesh Upadhyay
Updated on 18-May-2023 17:25:25
Files of Mixed Records In DBMS, file organizations are designed to handle records of a single type. However, in most real-world applications, multiple types of entities are interconnected in various ways. To represent relationships among records in different files, fields are connected. For example, a STUDENT record may have a connecting field Major_dept, whose value gives the name of the DEPARTMENT in which the student is majoring. The Major_dept field refers to a DEPARTMENT entity, which should be represented by a record of its own in the DEPARTMENT file. Retrieving field values from two related records requires retrieving one of ... Read More

Random password generator in C

Siva Sai
Updated on 18-May-2023 14:00:09
In this article, we will delve into an interesting and practical problem related to string manipulation in C programming. We are going to build a "Random Password Generator" in C. This problem not only enhances your understanding of string manipulation but also your knowledge of the C Standard Library. Problem Statement The task is to build a program that generates a random password of a specified length. The password should include uppercase and lowercase alphabets, digits, and special characters. C Solution Approach To solve this problem, we'll leverage the power of the C Standard Library. We'll use the rand() function ... Read More

Program to construct DFA for Regular Expression C( A + B)+

Siva Sai
Updated on 18-May-2023 12:34:45
In this article, we will be discussing how to construct a Deterministic Finite Automaton (DFA) for the Regular Expression C(A + B)+ using C++. We'll start by understanding the problem and the theory behind it, then we'll dive into the implementation and conclude with a relevant example to demonstrate its use. Understanding the Problem Statement A Deterministic Finite Automaton (DFA) is a theoretical model of computation used in automata theory, a branch of theoretical computer science. It's one of the simplest types of automata and an essential concept in the study of compilers and parsers. The task here is to ... Read More

Print a sorted list of words represented by the expression under the given grammar

Siva Sai
Updated on 18-May-2023 12:32:34
In this article, we will be exploring an interesting problem related to expressions and grammar in C++. The problem statement is "Print a sorted list of words represented by the expression under the given grammar". This problem offers a great opportunity to brush up your knowledge on parsing expressions, handling strings, and sorting algorithms in C++. Problem Statement Given a string expression where each character represents a lowercase English letter and the '|' character represents an OR operation, the task is to print a sorted list of all possible words represented by the expression. C++ Solution Approach Our approach to ... Read More

Permutation of a number whose sum with the original number is equal to another given number

Siva Sai
Updated on 18-May-2023 12:30:14
In this article, we'll delve into a fascinating problem that involves numbers and permutations: "Permutation of a number whose sum with the original number is equal to another given number". This problem offers a unique intersection of number theory and combinatorics, making it a compelling challenge to tackle. To clarify, given an original number and a target number, we need to find a permutation of the original number such that, when we add the original number and its permutation, we get the target number. Understanding the Problem In essence, this problem combines the concepts of number permutation, summation, and equality ... Read More
1 2 3 4 5 ... 124 Next
Advertisements