Dial implementation: Difference between revisions

From Algowiki
Jump to navigation Jump to search
Line 2: Line 2:
[[Category:Data Structures]]
[[Category:Data Structures]]
==General information==
==General information==
'''Abstract Data Structure:''' [[Bounded monotonous priority queue]]
'''Abstract Data Structure:''' [[Bounded monotonous priority queue]] where <math>{\cal K}</math> is an integral type and addition is defined on <math>{\cal K}</math>


'''Implementation Invariant:'''
'''Implementation Invariant:'''
# For each object of "Dial implementation", there is
# For each object of "Dial implementation", there is
## a specific '''maximum span of keys''' <math>S_\text{max}\in\mathbb{N}</math>,
## a specific '''maximum span of keys''' <math>S_\text{max}\in\mathbb{N}</math>,
## an array <math>A</math> with index set <math>\{0,\ldots,S-1\}</math> [[Set|sets]] of (key,value)-pairs,
## an array <math>A</math> with index set <math>\{0,\ldots,S-1\}</math> and [[Set|sets]] of keys as components,
## a '''current position''' <math>P\in\mathbb{N}_{0}</math>, which is dynamically changing,
## a '''current position''' <math>P\in\mathbb{N}_{0}</math>, which is dynamically changing,


All keys at an index of <math>A</math> are equal. For <math>i=P,P+1,P+2,\ldots,</math>
All keys at an index of <math>A</math> are equal. For <math>i\in\{0,\ldots,S-1\}\setminus\{P\}</math>, the value of the keys at position $i$ is larger than the value of the keys at index <math>P</math> by exactly <math>(S+i-P)\bmod S</math>. In particular, the minimum keys are at index $P$
 
In particular, the minimum key is associated with …


==Remark==
==Remark==

Revision as of 08:22, 7 October 2014

General information

Abstract Data Structure: Bounded monotonous priority queue where [math]\displaystyle{ {\cal K} }[/math] is an integral type and addition is defined on [math]\displaystyle{ {\cal K} }[/math]

Implementation Invariant:

  1. For each object of "Dial implementation", there is
    1. a specific maximum span of keys [math]\displaystyle{ S_\text{max}\in\mathbb{N} }[/math],
    2. an array [math]\displaystyle{ A }[/math] with index set [math]\displaystyle{ \{0,\ldots,S-1\} }[/math] and sets of keys as components,
    3. a current position [math]\displaystyle{ P\in\mathbb{N}_{0} }[/math], which is dynamically changing,

All keys at an index of [math]\displaystyle{ A }[/math] are equal. For [math]\displaystyle{ i\in\{0,\ldots,S-1\}\setminus\{P\} }[/math], the value of the keys at position $i$ is larger than the value of the keys at index [math]\displaystyle{ P }[/math] by exactly [math]\displaystyle{ (S+i-P)\bmod S }[/math]. In particular, the minimum keys are at index $P$

Remark

The implementations of the methods Bounded priority queue: number and Bounded priority queue: find minimum are trivial and, hence, left out here.

References