Questions tagged [subsequence]

A subsequence is a sequence obtained by deleting some elements and retaining the relative order of the remaining elements. It is a generalization of substring which contains only consecutive elements of the original sequence.

A subsequence is a sequence obtained by deleting some elements and retaining the relative order of the remaining elements. It is a generalization of substring which contains only originally consecutive elements.

303 questions
0
votes
2 answers

Find maximal subsequence of array with indexes

I would like to find the maximal subsequence S(h,k) in an array of integer. I already have the code (in Java) to find the maximum value and it works fine, but how can I get the two indexes h and k from the following? int []a = {-2, 1, -3, 4, -1, 2,…
Gio Bact
  • 541
  • 1
  • 7
  • 23
0
votes
1 answer

Find all recurrent substrings of length more then 1 in a huge string using Ruby/Python/C++/C

I have a complex problem at hand i.e. I have a huge(more than 200000 characters) :- '1213 1242 1213 49 1213 12134 4561213 154816 4631 154816' Output to be something like :- 1. No. of distinct recurrent patterns 2. Each's pattern's repitition count…
0
votes
1 answer

Longest palindrome subsequence VS Longest subsequence whose reverse is also a subsequence

I'm trying to think what is the difference between these two problems Given a sequence S 1) Find the longest palindrome subsequence of S. 2) Find the longest subsequence of S whose reverse is also a subsequence of S. The two subsequences could be…
HM9527
  • 111
  • 1
  • 1
  • 5
0
votes
1 answer

Issues with Longest Increasing Subsequence - Naive Approach

I was learning the fundamentals of dynamic programming and came over to the question of finding the Longest Increasing Subsequence in an array. Before looking up the DP solution, I decided to code it myself and came up with the following algorithm,…
Shubham Mittal
  • 1,545
  • 18
  • 21
0
votes
4 answers

Checking monotonicity of subsequences in Python

I want to be able to find the index of the end of a monotone decreasing subsequence which starts off at the first index of the list and only goes down in consecutive order. So for example, I may have a list that looks like this: x = [89, 88, 88,…
sos
  • 331
  • 2
  • 8
0
votes
2 answers

In Java how can I get a subsequence of number string whose indices can be as 10^5 digits long

In Java how can I get a subsequence of BigInteger whose indices can be 10^5 digits long. Example : BigInteger length is 10^5 . I have to find subsequence between index 10^3 and 10^4
khetanrajesh
  • 300
  • 3
  • 13
0
votes
0 answers

Extract non-Subsequences in data.frame

I have a data.frame: 1 2 3 4 A B C D A B C A C D A C A D A E G A G A K A D J P Above data.frame means these sequences: Sequence Is…
tshan
  • 39
  • 4
0
votes
0 answers

C++ Longest Common Subsequence Implementation errors O(n*m)

I'm going through some dynamic programming articles on geeksforgeeks and ran across the Longest Common Subsequence problem. I did not come up with an implementation of the exponential naive solution on my own, however after working out some examples…
Dominic Farolino
  • 1,362
  • 1
  • 20
  • 40
0
votes
1 answer

Is this sequence an increasing or decreasing subsequence?

I have a sequence of length 1. That is, 1 Now can I say that the longest increasing subsequence of length 1 in the above sequence is 1. And the longest decreasing subsequence of length 1 in the above sequence is 1 ?
user3243499
  • 2,953
  • 6
  • 33
  • 75
0
votes
1 answer

Python: Sub sequence search

I have a sequence 'abccabac' and a subsequence 'abc'. I need to get indices of all occurences of subsequence 'abc' in the sequence. What is the memory efficient way of doing it? Example: Input: **sequence**: 'abccabac' **subsequence**: 'abc' …
verdict_11
  • 35
  • 1
  • 1
  • 7
0
votes
1 answer

Minimum number of characters to be inserted in a string to convert it to palindrome

I need to find the minimal number of insertions needed to convert a string into a palindrome. Note: the insertions can happen at any place, at the end, or within. If it was only at the end, we have a question here. So I found out that this can be…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
0
votes
0 answers

Dynamic Programming: Find the Longest Subsequence?

In Cormen's Algorithms book, it gave an algorithms for finding the longest subsequene. When filling the table, it started from the lower right corner instead of the upper left corner: In short, it looked for the longest subsequence of two sequences…
Guppy_00
  • 165
  • 1
  • 1
  • 8
0
votes
3 answers

Why StringIndexOutOfBoundsException with subSequence?

I have a problem with Java and Android Studio; the following code was to be a backspace button: else if(view == btnBackspace){ int expressionLength = expression.length() - 2; String expressionNew = newExpression.subSequence(0,…
João Nobre
  • 51
  • 1
  • 10
0
votes
2 answers

Find the supersequence of given ordered subsequences in Java

I came across this problem in an unrelated program I'm writing and I've spent quite a few hours trying to solve it because I though it would be fun. It was but I was unable to do it all the way. My code only solves the sequence of some subsets. This…
0
votes
1 answer

Array being filled with garbage

I'm working on a longest common subsequence program and for some reason my array keeps being filled with garbage even after I init everything inside of it to NULL. #include "main.h" int main() { //Provided char arrays containing…
ryandonohue
  • 189
  • 4
  • 22