Found 34494 Articles for Programming

Find the single-digit sum of the alphabetical values of a string

Esha Thakur
Updated on 22-Jan-2024 18:16:06

213 Views

In order to find the single−digit sum of the alphabetical values of a string, we will explore the alphabetical values of a string and assign numerical values to letters of the alphabet. We will jump into the concept and an example to illustrate the steps involved, the algorithm behind this process, an example code implementation in C++, and finally a brief conclusion involving the significance of this technique. Concept The idea rotates around associating numerical values with each letter and performing arithmetic operations to calculate the single−digit sum i.e. 'A'=1 or 'a'=1, 'B'=2 or 'b'=2, and so on. By converting ... Read More

Implementing PCA in Python with scikit-learn

Someswar Pal
Updated on 05-Oct-2023 15:57:13

261 Views

Introduction Extraction of useful information from high-dimensional datasets is made easier by Principal component analysis, (PCA) a popular dimensionality reduction method. It does this by re-projecting data onto a different axis, where the highest variance can be captured. The complexity of the dataset is reduced while its basic structure is preserved by PCA. It helps with things like feature selection, data compression, and noise reduction in data analysis, and it can even reduce the dimensionality of the data being analyzed. Image processing, bioinformatics, economics, and the social sciences are just a few of the places PCA has been put to use. ... Read More

Maximum count of unique index 10 or 01 substrings in given Binary string

Shubham Vora
Updated on 05-Oct-2023 13:00:47

73 Views

In this problem, we will count the maximum number of 10 and 01 pairs that can be formed using the given binary string. To solve the problem, we can check the number of 10 and 01 pairs we can form using adjacent characters without sharing any characters in two pairs. Problem Statement We have given a bin_str binary string. We need to count the maximum number of 10 and 01 pairs we can make using the adjacent characters only. Also, we can use one character in any single pair. Two pairs can't share a single character. Sample Examples Input ... Read More

Java Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Updated on 05-Oct-2023 12:57:12

158 Views

In this problem, we will rotate the array by K left rotations and find the Mth element in the rotated array. The naïve approach to solve the problem is to rotate the array by K left rotation and take the element from the M – 1 index. The optimized approach is to find the final index value in such a way that the final index is the M – 1 index of the rotated array. Problem Statement We have given a nums[] array containing the positive integers. We have also given the positive integer K and M. We need ... Read More

Find index of pair among given pairs with just greater average

Shubham Vora
Updated on 05-Oct-2023 12:55:38

55 Views

In this problem, we will find the index value for each pair such that the resultant pair's average value is just greater than the current pair's average value. To solve the problem, we will use the sorting algorithm and binary search technique. We will use a sorting algorithm to sort the array based on the pair's average value and a binary search algorithm to search a pair with a greater average value from the sorted array. Problem Statement We have given a pairs[] array containing the N pairs of positive integers. It is also given that the first element of ... Read More

Count unique Strings by replacing Consonant with closest vowel and vice versa

Shubham Vora
Updated on 05-Oct-2023 12:51:25

52 Views

In this problem, we will count the number of unique strings we can generate by replacing each vowel with the closest consonant and each consonant with the closest vowel. We can find the number of choices for each character of the string to replace the current character with other characters. After that, we can multiply the number of choices of each character to get the answer. Problem Statement We have given an alpha string. We need to count the total number of different strings we can generate from the given string by performing the below operations on each character of ... Read More

How to Generate Unit Step, Sinusoidal and Exponential Signal in MATLAB?

Manish Kumar Saini
Updated on 05-Oct-2023 17:55:34

450 Views

These three types of signals (unit step, sinusoidal, and exponential) are basic signals used in analyzing different types of systems. A unit step signal has a step of magnitude one after a specific time instant. A sinusoidal signal is a type of signal which has either a sine or cosine waveform. A exponential signal is a type of signal that rises or decays exponentially with time. We can use MATLAB to generate all these types of signals. In this tutorial, I am going to explain how you can generate unit step, sinusoidal, and exponential signal in ... Read More

Can String be considered as a Keyword?

Shubham Vora
Updated on 05-Oct-2023 12:50:26

105 Views

Keywords are important in any programming language, as they are reserved words with a particular predefined meaning. The keywords are used to define the variables, function, and class, change the program's control flow, traverse the list, etc. When we talk about the 'String', it is a fundamental data type to represent a series of characters. Some programming languages refer to the 'String' as a class, and some programming languages refer to the 'String' as a keyword. In this tutorial, we will explore the use of the 'String' word in the programming language. C/C++ The C or C++ programming languages are ... Read More

How to Generate Periodic and Aperiodic Sequence in MATLAB?

Manish Kumar Saini
Updated on 05-Oct-2023 14:53:50

133 Views

A periodic sequence is one which repeats its pattern at regular intervals, whereas an aperiodic sequence is another type of sequence in which there is no regularity in the pattern. We can use MATLAB to generate periodic and aperiodic sequences. Before going to learn about generating periodic and aperiodic sequences using MATLAB, let us first get a brief overview of periodic and aperiodic sequences individually. What is a Periodic Sequence? A sequency of data points which has a regular pattern that repeats itself at a certain interval is called a periodic sequence. The interval over which the pattern of the ... Read More

C++ Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Updated on 05-Oct-2023 12:58:55

45 Views

In this problem, we need to print the element from the given index after rotating the array for K times. This problem teaches us to find the element from the particular index in the rotational array. At first sight, the solution that comes to mind is that rotate the array for K times and access the Mth element, but we will also learn to access the Mth element in the rotational array without rotating the array. Problem Statement We have given arr[] array containing N numbers. Also, we have given the positive integer M and K. We need to rotate ... Read More

Advertisements