Found 34494 Articles for Programming

Java Program to Implement Unrolled Linked List

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

105 Views

In this problem, we will learn to implement the unrolled linked list. The unrolled linked list is a specialized version of the linked list. The normal linked list contains a single element in a single node, but the unrolled linked list contains a group of elements in each node. Also, insertion, deletion, and traversal in the unrolled linked list work the same as the typical linked list. The linear search is faster in the array than in the linked list. So, we can add elements in the array and an array in each node of the linked list. Also, ... Read More

Java Program to Implement the Vizing's Theorem

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

55 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

126 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 31-May-2024 15:28:42

3K+ 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

582 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

264 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

69 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

Sum of all prefixes of given numeric string

Shubham Vora
Updated on 24-Aug-2023 17:48:33

95 Views

In this problem, we need to find the sum of all prefixes of the given string. The best solution approach is that traverse through each prefix of the string and add them to get the answer. Problem statement - We have given a string named num_Str containing N digits. We need to find the sum of all prefixes of the given string. Sample examples Input num_str = "1123" Output 1247 Explanation - All prefixes of the given strings are 1, 11, 112, and 1123. The sum of all prefixes is 1247. Input num_str = ... Read More

Minimize the cost to convert given string to either type XYXY… or XXYY…

Shubham Vora
Updated on 24-Aug-2023 17:46:19

62 Views

In this problem, we need to convert the given binary string to abababab or aabbaabb format and find the minimum cost for that. Also, we have given the cost to flip any character in the operations array. Problem statement - We have given a bin_str binary string and operations array containing the positive integers. The size of the string and array is the same and even. The task is to find the minimum costs to convert the string in the ababab… or aabbaabb… format. The cost to flip any character in the given string is the value at the ... Read More

Maximum string length after choosing strings from given Array with given conditions

Shubham Vora
Updated on 24-Aug-2023 17:32:53

120 Views

In this problem, we need to find the maximum length of the resultant string by appending the array strings to it such that if we choose a string of length x, we can choose the next x/2 strings. We can solve the programming using the recursive function, memoization, and dynamic programming approach. Problem statement - We have given an array of strings named str_array containing the N strings. We need to add the strings given in the array and find the maximum size of the resultant string. While appending the string to the resultant string, we need to ... Read More

Advertisements