Found 2620 Articles for Java

Java Program to Implement the Vizing's Theorem

Shubham Vora
Updated on 24-Aug-2023 18:07:17

41 Views

In this problem, we need to implement Vizing's Theorem. Vizing's Theorem is used with graphs. Theorem statement - For any undirected graph G, the value of the Chromatic index is equal to the d or d + 1, where d is the maximum degree of the graph. The degree for any vertex is the total number of incoming or outgoing edges. Problem statement - We have given a graph and need to implement Vizing's Theorem to find the Chromatic index of the graph. Note - The chromatic index is a positive integer, requiring a ... Read More

Java Program to Implement the Schonhage-Strassen Algorithm for Multiplication of Two Numbers

Shubham Vora
Updated on 24-Aug-2023 18:04:22

114 Views

The Schonhage-Strassen algorithm is useful when we need to multiply large decimal numbers. As Java supports the 1018 size of integers, and if we need to multiply the digits of more than 1018, we need to use the Schonhage-Strassen algorithm, as it is one of the fastest multiplication algorithms. It uses the basic rules for the multiplication of two numbers. It first performs the linear convolution and then performs the carry to get the final result. Problem statement - We have given mul1 and mul2 large decimal numbers and need to implement the Schonhage-Strassen algorithm to multiply both ... Read More

Java Program to Implement the RSA Algorithm

Shubham Vora
Updated on 24-Aug-2023 18:02:58

2K+ Views

The RSA name is given by their inventors which is used to encrypt the text with high security. The RSA technique is one of the most used techniques to encrypt text, as it is the asymmetric encryption algorithm. It encrypts the text by utilizing the mathematical properties of the prime numbers. In the RSA algorithm, the sender and receiver have private keys. Also, a common public key exists, which the sender shares with the receiver. The sender encrypts the plain text using their own public and private key, and the receiver decrypts the message using their private and public ... Read More

Java Program to Implement the Monoalphabetic Cypher

Shubham Vora
Updated on 24-Aug-2023 18:01:42

465 Views

In this problem, we need to convert the text to cipher text using the Monoalphabetic Cipher technique. All alphabetical characters are pre-mapped to their cipher character in the Monoalphabetic Cipher algorithm. So, we need to substitute all plain text characters with their mapped characters. Here is the table containing the mapping of characters. a$\mathrm{\rightarrow;}$Q b $\mathrm{\rightarrow;}$ W c $\mathrm{\rightarrow;}$ E d $\mathrm{\rightarrow;}$ R e $\mathrm{\rightarrow;}$ T ... Read More

Java Program to Implement the Linear Congruential Generator for Pseudo Random Number Generation

Shubham Vora
Updated on 24-Aug-2023 17:59:40

231 Views

A Linear Congruential Generator (LCG) is a technique to generate a sequence of numbers that looks like random numbers but are actually determined. It is one of the reasons to call it a pseudo-random number. The Linear Congruential Generator (LCG) technique generates a random number based on the previous number and uses linear recurrence to generate the sequence of the random number. We can use the below formula of LCG to generate random numbers based on the previous numbers. $$\mathrm{x_{n+1}=(mult\:x_{n}+\:increment\:mod\:modulus)}$$ In the above formula, the 'mod' presents the modulus operation. $\mathrm{x_{n+1}}$ - ... Read More

Java Program to Implement the String Search Algorithm for Short Text Sizes

Shubham Vora
Updated on 24-Aug-2023 17:56:59

49 Views

In this problem, we need to find the index of the pattern in the string. Implementing an efficient text search is very important to allow users to search large text databases easily. For example, you are writing a blog in Microsoft Word or code in VSCode, containing 1 lakh+ word. If the search algorithm is inefficient, it can take time to show you search results when searching for any word or sentence. We will learn two different approaches to implementing the string search algorithm. One is the naïve approach, and another is the KMP algorithm. Problem statement - ... Read More

Java Program for Queries for rotation and Kth character of the given string in constant time

Shubham Vora
Updated on 24-Aug-2023 16:53:07

40 Views

In this problem, programmers require to execute the queries on the string. Also, need to rotate the string and print the characters of the updated string. The best approach to solve the problem is that keep updating the index value and access string characters when we need to print the character. Problem statement – We have given the string alpha and the array containing the pair of numbers named ‘que’. The task is that perform the queries given in the array onto the string alpha. Follow the below query operation rules. (1, a) – Make total left rotations of ... Read More

Java Program for Check if a string can be formed from another string by at most X circular clockwise shifts

Shubham Vora
Updated on 24-Aug-2023 16:45:26

46 Views

In this problem, we need to convert one string to another by performing at most x circular shift operations on each character of the first string. The naïve approach to solving the problem is to rotate each character of the alpha1 string for x times, and we check if it matches the character of the alpha2 string, which is at the same index. The second approach is to solve the problem by finding the circular difference between characters at the same index. Problem statement – We have given a positive integer X. Also, we have given a string alpha1 ... Read More

Find Words which are Greater than given Length k using Stringstream

Avinash Gupta
Updated on 23-Aug-2023 21:30:42

156 Views

This is the problem based on stringstream class present in C++ “sstream” header file. Here, we have to find those strings whose lengths are greater than “k”. This task will be performed by using stringstream class. The concept is to partition the string and then iterate through the defined words. The value of length k has to be specified to obtain the words which are larger than k whereas the length of the words which are smaller than k will not be displayed in the output. In this article, we will understand how to find words which are greater than ... Read More

Length of Longest Common Subsequence Containing Vowels

Avinash Gupta
Updated on 23-Aug-2023 21:28:51

100 Views

In this problem, our task is to find the length of the longest possible subsequence present in two strings such that every letter of the subsequence must be a vowel. With the help of the recursive algorithm and iterative algorithm, the given problem statement can be solved. In English Alphabet, there exist five vowels named 'A', 'E', 'I', 'O', 'U'. Subsequence Vs. Substring: In Subsequence, we may take characters in a non-continuous way, but in Substring, we can take only continuous characters. Ex: In String “TutorialsPoint”: “tri” is a subsequence but not a substring. While “tor” is both subsequence ... Read More

Advertisements