Merging two sorted sequences: Difference between revisions

From Algowiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ Category:Checkup Category:Algorithmic Problem Category:Basic Problems on Sequences ==Input== Two Sets and sequences#Ordered and sorted sequences|sorted...")
 
 
Line 4: Line 4:
[[Category:Basic Problems on Sequences]]
[[Category:Basic Problems on Sequences]]
==Input==
==Input==
Two [[Sets and sequences#Ordered and sorted sequences|sorted sequences]], <math>S_{1}</math> and <math>S_{2}</math>, that have identical component type and identical definition of [[Genericity#Comparison|comparison]].
# Two [[Sets and sequences#Ordered and sorted sequences|sorted sequences]], <math>S_{1}</math> and <math>S_{2}</math>, that have identical component type.
# A [[Genericity#Comparison|comparison]] on this component type.


==Output==
==Output==

Latest revision as of 09:22, 20 May 2015

Input

  1. Two sorted sequences, [math]\displaystyle{ S_{1} }[/math] and [math]\displaystyle{ S_{2} }[/math], that have identical component type.
  2. A comparison on this component type.

Output

A sorted sequence [math]\displaystyle{ S }[/math], whose element set is the union of the element sets of [math]\displaystyle{ S_{1} }[/math] and [math]\displaystyle{ S_{2} }[/math], sorted according to the same definition of comparison.

Objective

N/A

Complexity

Linear in the sum of the lengths of the input sequences.

Known algorithms

Merge