Karthikeya Boyini has Published 2193 Articles

Median of two sorted array

karthikeya Boyini

karthikeya Boyini

Updated on 16-Jun-2020 09:23:44

727 Views

Medians are the middle numbers, in other words, the median value is the middle observation in an ordered list. It corresponds to the cumulative percentage of 50%.The size of two arrays must be same, we will find the median of two separate arrays at first, then compare the separate medians ... Read More

How to move an array element from one array position to another in Java?

karthikeya Boyini

karthikeya Boyini

Updated on 16-Jun-2020 08:43:04

14K+ Views

To move an element from one position to other (swap) you need to –Create a temp variable and assign the value of the original position to it.Now, assign the value in the new position to original position.Finally, assign the value in the temp to the new position.ExampleLive Demoimport java.util.Arrays; ... Read More

M-Coloring Problem

karthikeya Boyini

karthikeya Boyini

Updated on 16-Jun-2020 07:58:12

8K+ Views

In this problem, an undirected graph is given. There is also provided m colors. The problem is to find if it is possible to assign nodes with m different colors, such that no two adjacent vertices of the graph are of the same colors. If the solution exists, then display ... Read More

Rat in a Maze Problem

karthikeya Boyini

karthikeya Boyini

Updated on 16-Jun-2020 07:23:16

5K+ Views

In this problem, there is a given maze of size N x N. The source and the destination location is top-left cell and bottom right cell respectively. Some cells are valid to move and some cells are blocked. If one rat starts moving from start vertex to destination vertex, we ... Read More

Subset Sum Problem

karthikeya Boyini

karthikeya Boyini

Updated on 16-Jun-2020 07:09:28

15K+ Views

In this problem, there is a given set with some integer elements. And another some value is also provided, we have to find a subset of the given set whose sum is the same as the given sum value.Here backtracking approach is used for trying to select a valid subset ... Read More

Rabin-Karp Algorithm

karthikeya Boyini

karthikeya Boyini

Updated on 15-Jun-2020 19:24:52

2K+ Views

Rabin-Karp is another pattern searching algorithm to find the pattern in a more efficient way. It also checks the pattern by moving window one by one, but without checking all characters for all cases, it finds the hash value. When the hash value is matched, then only it tries to ... Read More

Trie of all Suffixes

karthikeya Boyini

karthikeya Boyini

Updated on 15-Jun-2020 19:10:41

511 Views

From the text, we can generate all suffixes to make a tree structure. We know that every pattern that presents in the text, must be a prefix of one of the possible suffix in the text. By building Trie of all suffixes, we can find any substring in linear time. ... Read More

kasai’s Algorithm

karthikeya Boyini

karthikeya Boyini

Updated on 15-Jun-2020 19:00:01

689 Views

Kasai’s Algorithm is used to get the Longest Common Prefix (LCP) array from suffix array. At first suffix arrays are found. After that Kasai's algorithm takes the suffix array list to find LCP.For the LCP array, it takes O(m log n), where m is pattern length and n is the ... Read More

Manacher’s Algorithm

karthikeya Boyini

karthikeya Boyini

Updated on 15-Jun-2020 18:40:57

718 Views

To find the longest palindromic substring from a string, we can use Manacher’s Algorithm. By selecting each character, we will try to find if there any palindrome using left and right pointer. There is another array to store information, from that information we can easily find how long the palindrome ... Read More

Anagram Pattern Search

karthikeya Boyini

karthikeya Boyini

Updated on 15-Jun-2020 17:47:44

563 Views

Anagrams are basically all permutations of a given string or pattern. This pattern searching algorithm is slightly different. In this case, not only the exact pattern is searched, it searches all possible arrangements of the given pattern in the text.To solve this problem, we will divide the whole texts into ... Read More

Advertisements