To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Run of a sequence

From Wikipedia, the free encyclopedia

In computer science, a run of a sequence is a non-decreasing range of the sequence that cannot be extended. The number of runs of a sequence is the number of increasing subsequences of the sequence. This is a measure of presortedness, and in particular measures how many subsequences must be merged to sort a sequence.

YouTube Encyclopedic

  • 1/3
    Views:
    81 286
    60 454
    319 088
  • Computer Science Basics: Sequences, Selections, and Loops
  • What is Sequence? | Coding for Kids | Kodable
  • Fetch Decode Execute Cycle in more detail

Transcription

Definition

Let be a sequence of elements from a totally ordered set. A run of is a maximal increasing sequence . That is, and [clarification needed] assuming that and exists. For example, if is a natural number, the sequence has the two runs and .

Let be defined as the number of positions such that and . It is equivalently defined as the number of runs of minus one. This definition ensure that , that is, the if, and only if, the sequence is sorted. As another example, and .

Sorting sequences with a low number of runs

The function is a measure of presortedness. The natural merge sort is <span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math alttext="{\displaystyle {\mathtt {runs}}}" xmlns="http://www.w3.org/1998/Math/MathML"> <semantics> <mrow class="MJX-TeXAtom-ORD"> <mstyle displaystyle="true" scriptlevel="0"> <mrow class="MJX-TeXAtom-ORD"> <mrow class="MJX-TeXAtom-ORD"> <mi mathvariant="monospace">r</mi> <mi mathvariant="monospace">u</mi> <mi mathvariant="monospace">n</mi> <mi mathvariant="monospace">s</mi> </mrow> </mrow> </mstyle> </mrow> <annotation encoding="application/x-tex">{\displaystyle {\mathtt {runs}}}</annotation> </semantics> </math></span><img alt="{\displaystyle {\mathtt {runs}}}" aria-hidden="true" class="mwe-math-fallback-image-inline mw-invert" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/18d9447c84e1a6fcc3b63642b4ebf5586eeec55e" style="vertical-align: -0.338ex; width:4.882ex; height:1.676ex;"/></span>-optimal. That is, if it is known that a sequence has a low number of runs, it can be efficiently sorted using the natural merge sort.

Long runs

A long run is defined similarly to a run, except that the sequence can be either non-decreasing or non-increasing. The number of long runs is not a measure of presortedness. A sequence with a small number of long runs can be sorted efficiently by first reversing the decreasing runs and then using a natural merge sort.

References

  • Powers, David M. W.; McMahon, Graham B. (1983). "A compendium of interesting prolog programs". DCS Technical Report 8313 (Report). Department of Computer Science, University of New South Wales.
  • Mannila, H (1985). "Measures of Presortedness and Optimal Sorting Algorithms". IEEE Trans. Comput. (C-34): 318–325.
This page was last edited on 26 February 2022, at 10:07
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.