real analysis – Show that a subsequence is a subset of the original sequence

My main question is the 4th point, but I hope you can clarify some things for me along the way.

The definition of a sequence says that a function $ a: mathbb {N} to S $ is a sequence on a set $ S $, denoted $ (a_n) $.

  1. Can i freely restrict the area of ​​function $ a $ and still call it a sequence? In particular, a) is it valid to define $ a_n $ on a finite subset of $ mathbb {N} $ b) on an infinite subset of $ mathbb {N} $?

Let's say that at each term in the sequence $ (a_n) _ {n in mathbb {N}} $, I have to define a new sequence from there. I first define a sequence $ (m_k) $ who maps $ {k in mathbb {N}: k geq n } to mathbb {N}, forall n in mathbb {N} $ with $ m_k <m_ {k + 1} $ (assuming affirmative on question 1b because the domain is an infinite subset of $ mathbb {N} $). Then, like $ (a_ {m_k}) $ is the composition of the sequence $ (a_n) $ and the increasing sequence $ (m_k) $, by definition $ (a_ {m_k}) $ is a subsequence of $ (a_n) $.

  1. Is it a good way to show that these new sequences $ (a_ {m_k}) $ are subsequences?

A set of points defined for the sequence $ (a_n) $ East $ left {a_n: n in mathbb {N} right } $.

  1. How do you define a set of points for a subsequence $ (a_ {m_k}) $? East $ forall n in mathbb {N}, left {a_ {m_k}: k geq n right } $ well?

Assuming yes on question 3, the main question is:

  1. How to prove this $ forall n in mathbb {N}, left {a_ {m_k}: k geq n right } subseteq left {a_n: n in mathbb {N} right } $? In other words, that the set of points defined for a subsequence is a subset of the set of points in the original sequence. I think i should take a term off $ left {a_ {m_k}: k geq n right } $ and deduce that its also in the whole $ left {a_n: n in mathbb {N} right } $, but I don't know how to do it rigorously.

To give you context on my questions, I want to show that $ sup { left {a_n: n in mathbb {N} right }} geq sup { left {a_ {k}: k geq n right }} $. Given that $ (a_n) $ is bounded, defines $ left {a_n: n in mathbb {N} right } $ and $ left {a_ {k}: k geq n right } $ are delimited. Having $ left {a_ {k}: k geq n right } subseteq left {a_n: n in mathbb {N} right } $ I would prove the supremums as in the question Prove the supremum of a subset is smaller than the supremum of the whole.

Longest word in the dictionary that is a subsequence of a given string. Javascript!
const sampleString = "infatuated";

const dictionary = Object.freeze((

data structures – Check if each prefix sum of the subsequence is $> = 0 $ and the sum is $ = 0 $

Consider the sequences whose elements are -1.0.1 $.
Subequence $ A (i … j) $ East $ good $ if sum of its elements $ = $ 0.
Example: for sequence $ 1.10, -1, -1.1 subsequence $ 1.0, -1, -1.1 East $ good $.

The consequence $ A (i … j) $ East $ supergood $ if it is good and each sum of its prefix is $> = 0 $
Example: for sequence $ 1.10, -1, -1.1 subsequence $ 1.0, -1, -1.1 is not $ supergood $ But 1.0, -1 $ East $ supergood $.

Now, I want to have a dynamic data structure that allows Mi to effectively perform these operations:

  • Insert (S, x, i) – inserts $ x $ in $ S $ sure $ i $& # 39; e position
  • Delete (S, i) – Delete $ i $& # 39; e element
  • isSuperGood (S, i, j) – checks if the subsequence $ i $, $ j $ is super good

The solution could be an AVL tree with a sum of elements in the left and right subtrees. It is easy to update and allows us to check if the subsequence is good in O (log (n)):

  1. Find the node i (say v) O (log (n))
  2. Find the node j (say u) O (log (n))
  3. Check if v.val + vl.lsum – u.lsum + u.val == 0 O (1)

But if it is a question of checking the super good condition, I do not see how.

Longest palindromic subsequence / substring and dynamic programming

The longest palindromic subsequence the problem can be solved using dynamic programming as it is recursive and has overlapping sub-problems, as described in

On the other hand, AFAIK there is no dynamic programming solution for the longest palindromic substring problem. The DP solution presented at does not use DP for the original LP substring problem, but for the substring -problem of finding if a substring is palindromic. The global solution consists in comparing the length of all the palindromic substrings, just like in the naive solution; the only difference is that DP is used to speed up the search process if each substring is palindromic, which reduces the time complexity from O (n ^ 3) to O (n ^ 2).

Why is there a DP solution for the LP subsequence problem, but not for the substring problem? Is it because the former can be expressed by recursion and the latter cannot?

Dynamic Programming – Find the "Best" Sub-Sequence The Longest Common

I write a program that calculates and displays the diffs. I have implemented the Meyers algorithm which calculates the LCS between 2 subsequences (seq1 and seq2) its output is one of the possible LCS and a partition of seq1 and seq2whose projection is lcs.

I want to improve it so that the displayed LCS minimizes the number of breaks; to do this, I implemented a function f(lcs, seq):

  • seq is a sequence of characters
  • lcs is a subsequence of seq
  • the output is a partition of seq p0, p1, p2, ... pn such as
    • no more p0 + p2 + or p1 + p3 + ... is lcs
    • and n is minimal

I did it using some kind of BFS, at every step, finding the next item not covered in lcs in seq and eagerly enlarge the common part.

The resulting algorithm is quite slow: on a typical input, about 3 times slower than the Myers algorithm, which seems to calculate something much more complex. See the code here:

Am I missing a better algorithm?

c ++ – Why does this longer-escalation sub-sequence problem not work properly?

I have defined recursively to work case by case. I'm getting wrong answers using large enough test data, but it works well for smaller cases.

  int LIS(100000);
  void LS (int *arr , int n)
      if (n == 0)
          LIS(0) = 1;
      if (LIS(n))
      int i = 0;
      int max = 0;
      while (i < n)
          if (arr(i) < arr(n))
              if (LIS(i) + 1 > max)
                  max = 1 + LIS(i);
      LIS(n) = max;

  int main()
      int n;
      std::cin >> n;
      int arr(n);
      for(int i = 0 ; i < n ; ++i) std::cin >> arr(i);
      std::sort (LIS , LIS+n);
      std::cout << "n" << LIS(n-1) << "n";

calculation – Let a_n be a sequence and assume that sup (a_n) = ∞. Prove that there is a subsequence b_k = a_nk such that b_k tends to.

Can someone help me?
I do not know where to start even these questions

Let a be a sequence and suppose that there exists a subsequence bk = ank such that bk tends to ∞. Prove that sup (an) =.

Let a be a sequence and suppose that supan =. Prove that there is a subsequence bk = ank such that bk tends to

real analysis – Convergent subsequence of $ sin (n ^ 2) $

What can we say about convergent subsequences of $ sin (n ^ 2) $ whose existence is guaranteed by the Bolzano-Weierstrass Theorem?

Can we, as a corollary, affirm that for all $ epsilon gt $ 0 it exists $ m, n in mathrm {N} $ such as $ | sin (n) – sin (m) | lt epsilon $ ?

Grammar without context of the concatenation of an S string and an inverted S subsequence

Instead of trying to remove some symbols from $ x $ in order to obtain $ y $, let's try to add some symbols to $ y $ so that we will get a "supersquence" of $ y ^ R $, who will be $ x $. Deletion is difficult to achieve because the activity of context-free grammar is to generate.

Starting from $ # $, we will either add the same symbol on both sides, or add a symbol only on the left side. Hence the following simple grammar.

$$ S to # mid aSa mid bSb mid aS mid bS $$

Exercise. find a grammar without context that generates the language:

$ L_ {a, b} = {xy mid x text {with some} a text {is identical to} y text {with some} b text {inserted. } x, y in {a, b } ^ * } $.

algorithms – maximum GCD per pair of an even subsequence

I'm trying to solve a particular problem, where I've given an array of integers and an integer X and I have to choose a subsequence of the array whose gcd pair is maximal given that the Sub-sequence size should not exceed 2 * X.

So, for example, my table is (5, 7, 10, 8, 3, 4) and X is 2:
the answer would be 9 since GCD (5, 10) + GCD (8, 4) = 9

The only approach I could find was this: at each step, I will find the maximum calculation of the pairwise value of the numbers, then remove the 2 numbers from the array.
Let's continue to add it to a sum (that I have to go out), under the constraints that I do not take more than 2 * X numbers.