https://www.algopedia.ro/wiki/index.php?title=Problems_Involving_Sequences&feed=atom&action=historyProblems Involving Sequences - Revision history2021-08-03T20:41:59ZRevision history for this page on the wikiMediaWiki 1.34.0https://www.algopedia.ro/wiki/index.php?title=Problems_Involving_Sequences&diff=1650&oldid=prevCristian: Add search in a sequence2011-01-13T12:59:04Z<p>Add search in a sequence</p>
<p><b>New page</b></p><div>= Problems with Sequences =<br />
<br />
This is a small list of exercises involving sequences of numbers, for beginners. They do not require storage, thus they have solutions without using arrays.<br />
<br />
== Problems with sequences (no arrays needed) ==<br />
<br />
=== Even Elements ===<br />
How many even elements are in a sequence of <code>n</code> integer numbers?<br />
=== Signed Elements ===<br />
How many negative, zero, and positive elements does a sequence of <code>n</code> numbers contain?<br />
=== Sum and Product ===<br />
Compute the sum and the product of numbers <code>1</code> to <code>n</code>, <code>n</code> given. Is there a complexity difference between the best algorithms you can find for the two?<br />
=== Find Element ===<br />
Given a number <code>a</code> and a sequence of <code>n</code> elements, on what position does <code>a</code> appear in the sequence?<br />
=== Indices and Elements ===<br />
How many numbers in a sequence of <code>n</code> elements are equal to the position in which they appear in the sequence?<br />
=== Increasing Sequence ===<br />
Are the numbers in a sequence in increasing order?<br />
=== Maximum and minimum ===<br />
Compute the maximum and the minimum value in a sequence of <code>n</code> numbers.<br />
=== Fibonacci numbers ===<br />
Compute the <code>n<sup>th</sup></code> number in the Fibonacci sequence. The Fibonacci sequence has <code>f<sub>1</sub> = 0</code>, <code>f<sub>2</sub> = 1</code> and <code>f<sub>n</sub> = f<sub>n-1</sub> + f<sub>n-2</sub></code>. Example: <code>0 1 1 2 3 5 8 13 21 ...</code><br />
=== Monotonic Sequence ===<br />
Is a sequence of numbers monotonic? We define a <span style=color:green>'''monotonic sequence'''</span> as a sequence whose numbers are either in increasing order, or in decreasing order.<br />
=== Identical Numbers ===<br />
What is the maximum number of consecutive identical numbers in a sequence of <code>n</code> elements?<br />
=== Adding fractions ===<br />
Given a sequence of numbers <code>a<sub>1</sub> a<sub>2</sub> ... a<sub>n</sub></code> compute the summation <math>\sum_{k=1}^n \frac{1}{a_k} = \frac{1}{a_1} + \frac{1}{a_2} + ... + \frac{1}{a_n}</math><br />
<br />
=== Word Counting ===<br />
How many groups of consecutive non-zero numbers are in a sequence? Consider such groups as words, zero being a divider such as space.<br />
=== Rotating Sequence <sup>h</sup> ===<br />
Let's define a <span style=color:green>'''rotating increasing sequence'''</span> as a sequence of numbers that is either in increasing order, or can be transformed into one by successive rotations (the last element becomes first). Problem: is a sequence of <code>n</code> numbers a rotating increasing sequence?<br />
=== Rotating Monotonic Sequence <sup>h</sup> ===<br />
Same as before we define a <span style=color:green>'''rotating monotonic sequence'''</span> as a sequence that is either monotonic, or can be made into one by rotations. Problem: is a sequence of <code>n</code> numbers a rotating monotonic sequence?<br />
=== Bitonic Sequence <sup>h</sup> ===<br />
Is a sequence of numbers bitonic? We define a <span style=color:green>'''bitonic sequence'''</span> as a sequence whose numbers are begin in increasing order, and then start decreasing and remain decreasing until the end of the sequence. Increasing and decreasing sequences are also bitonic sequences (that is, it's allowed to skip one of the two sections).<br />
=== Rotating Bitonic Sequence <sup>h</sup> ===<br />
Same as before we define a <span style=color:green>'''rotating bitonic sequence'''</span> as a sequence that is either bitonic, or can be made into one by rotations. Problem: is a sequence of <code>n</code> numbers a rotating bitonic sequence?<br />
=== Brackets <sup>h</sup> ===<br />
Given a sequence of <code>0</code> and <code>1</code>, where <code>0</code> means open bracket and <code>1</code> means close bracket, find out if the sequence represents a correct sequence of brackets, and if so, compute the maximum number of nested brackets. Example: <code>0 1 0 0 1 0 1 1</code> is correct and has a maximum nesting factor of 2, while <code>0 0 1 1 1 0</code> is incorrect.<br />
<br />
<br />
<br />
<br />
<br />
''Legend:''<br />
* '''<sup>h</sup>''' means '''h'''ard. The problem is difficult.</div>Cristian