In CodeChef (an online programming contest) I encountered a problem where they used the term "sequence of $N$ integers" and give the examples "3, 2, 4" and "3, 1, 3".

How can these be sequences? Am I missing something?

  • $\begingroup$ Do you have a problem that the sequence is finite (e.g. does not go on further) or do you want the first sequence given as $a_1=3, a_2=2,a_3=4$? $\endgroup$
    – Ingix
    Mar 3 '19 at 19:20
  • $\begingroup$ As @Ilmari clarifies in an edit, the phrase used is "sequence of $N$ integers". If $N$ is, say, $3$, then what would you think "sequence of $3$ integers" means, if not something like "3, 2, 4" or "3, 1, 3"? $\endgroup$
    – Blue
    Mar 3 '19 at 19:38
  • $\begingroup$ @Blue A sequence should be an ordered list . Is there any order you can find? $\endgroup$ Mar 3 '19 at 20:58
  • $\begingroup$ Welcome to Mathematics Stack Exchange! A quick tour will enhance your experience. Here are helpful tips to write a good question and write a good answer. For equations, please use MathJax. $\endgroup$
    – dantopa
    Mar 4 '19 at 1:25
  • $\begingroup$ @dynamicprogramming: Order is clear. In "3, 2, 4", the "3" is first, "2" is second, and "4" is third. While order isn't particularly relevant to the task at hand ("2, 4, 3" and "2, 3, 4" give identical results), assigning indices is important for distinguishing repeated elements. $\endgroup$
    – Blue
    Mar 4 '19 at 4:54

It's a matter of definition. To quote Wikipedia (which, while not authoritative, does provide a nice and comprehensive overview of the subject):

For the purposes of this article, we define a sequence to be a function whose domain is an interval of integers. This definition covers several different uses of the word "sequence", including one-sided infinite sequences, bi-infinite sequences, and finite sequences (see below for definitions). However, many authors use a narrower definition by requiring the domain of a sequence to be the set of natural numbers. The narrower definition has the disadvantage that it rules out finite sequences and bi-infinite sequences, both of which are usually called sequences in standard mathematical practice.

Basically, some authors like to define the term "sequence" narrowly as having a definite beginning but no end, while others use the same term also for finite sequences with both a beginning and an end, or may even allow doubly infinite sequences that extend infinitely in both directions with neither a beginning nor an end. Sometimes, one might even encounter "sequences" with more complicated order types.

The narrow definition does have some advantages, particularly when dealing with things like the convergence and limits of sequences, which are have clear and universally agreed-upon definitions for infinite sequences, but may or may not even make sense when applied to finite sequences. But if one is not purely concerned with convergence and limits, there are many contexts where it makes sense to consider finite sequences as well. Of course, one could choose to use some other term for them, such as "tuple", but "sequence" is such a common and widely understood English word that it can seem a bit silly to avoid using it, in the whole scope of its common meaning, just because a certain subarea of mathematics has chosen to define it more narrowly.

Fortunately, in most cases it's perfectly obvious from context what kind of sequence is meant anyway. In particular, if you're given a finite sequence like $(1,2,3)$, it seems pretty pointless to complain that it cannot be a sequence because it's not infinite. Rather, you should just assume that the author is using the word "sequence" in the broader sense, and move on.

  • $\begingroup$ @dynamicprogramming: By convention, lists and sequences are read in the same direction as written English is read in general, i.e. from left to right. $\endgroup$ Mar 3 '19 at 20:46
  • $\begingroup$ It should be , Given an array of N integers/N integers rather than sequence of N integers since sequence means ordered things. $\endgroup$ Mar 3 '19 at 21:31
  • $\begingroup$ @dynamicprogramming: I believe that, in most (all?) programming languages, "array" also means "ordered things", so you don't seem to have addressed your own objection. For unordered things, the appropriate term is "set" (or "multi-set", to allow repeated elements). Even so, in performing the task, you're probably going to want to impose an order on the elements to keep them straight, so calling the collection a "sequence" (or "array") from the start doesn't seem out of line. In any case, your concern seems to be more about coding terminology than about mathematical definition. $\endgroup$
    – Blue
    Mar 4 '19 at 5:09
  • $\begingroup$ Thank you. I got it. $\endgroup$ Mar 5 '19 at 11:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.