Sorted sequence: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
'''Input:''' | '''Input:''' | ||
'''Output:''' A [[Linear sequence]] <math>L</math> containing all elements of the sorted sequence in | '''Output:''' A [[Linear sequence]] <math>L</math> containing all elements of the sorted sequence in ascending order. | ||
'''Precondition:''' | '''Precondition:''' |
Revision as of 11:04, 26 September 2014
General Information
Representation invariant:
- The abstract data structure sorted sequence implements sorted sequences as defined here.
- This abstract data structure is generic and parameterized by a fixed key type [math]\displaystyle{ \kappa }[/math] and a fixed comparision [math]\displaystyle{ c }[/math] defined on [math]\displaystyle{ \kappa }[/math].
Constructor: Gets a comparision [math]\displaystyle{ c }[/math] and initializes ths sequence so as to be empty.
Insert
Input: A key [math]\displaystyle{ K \in \kappa }[/math].
Output:
Precondition:
Postcondition: A new element with the key [math]\displaystyle{ K }[/math] is inserted at the appropriate position in sorting order.
Traverse
Input:
Output: A Linear sequence [math]\displaystyle{ L }[/math] containing all elements of the sorted sequence in ascending order.
Precondition:
Postcondition: All keys of the sorted sequence are appended to [math]\displaystyle{ L }[/math] in ascending order.