Method and apparatus for sorting elements
The present invention pertains to a method for sorting. The method comprises the steps of forming a decision tree comprised of at least a first level having at least a first entry with either a first result or a second result corresponding to values as they fill a queue. Then, there is the step of reading the result in the first entry of the first level of the decision tree. Next, there is the step of choosing the value in the first entry of the first level from the queue corresponding to the result in the first entry. The present invention comprises a priority queue. The priority queue comprises an array in which elements are stored. Also, the priority queue comprises a controller which stores the elements in the array with no memory reads and a constant number of memory writes so a smallest element in the array can be identified.
Latest FORE Systems, Inc. Patents:
Claims
1. A method for sorting comprising the steps of:
- forming a decision tree comprised of at least a first level having at least a first entry with either a first result or a second result corresponding to values as they fill a queue;
- reading the result in the first entry of the first level of the decision tree; and
- choosing the value from the queue corresponding to the result in the first entry.
2. A method for sorting comprising the steps:
- forming a decision tree comprised of N levels, where N.gtoreq.-1 and is an integer and corresponds to a queue of 2.sup.N elements each having a value, as the queue is filled, each level L having 2.sup.L entries where L.gtoreq.0 and is an integer, each entry having either a first result or a second result corresponding to values in the queue;
- reading the results in the entry of the 0th level;
- reading the results in the entries of subsequent higher levels, if any, depending on the result read in a previous lower level; and
- choosing the value from the queue corresponding to the result in the entry in a highest level.
3. A method as described in claim 2 wherein L.gtoreq.1 and wherein the step of reading the results in the entries of the subsequent higher levels includes the step of reading the entry in the first level depending on the result in the entry in the 0th level; and wherein the choosing step includes the step of choosing the value from the queue corresponding to the result read in the entry of the first level.
4. A method as described in claim 3 wherein the forming step includes the steps of writing a first value into the first element of the queue;
- writing a second value into the second element of the queue;
- comparing the second value with the first value;
- writing the first result or second result into a corresponding entry of the first level for the corresponding elements depending on whether the first value is greater than or less than the second value, respectively; and
- repeating the step of writing, comparing and writing a third value in regard to the second value and a corresponding entry; and
- comparing the third value to the smallest of the first and second values, and writing the first result or second result into a corresponding entry of the 0th level for the corresponding elements depending on whether the third value is greater than or less than the second value, respectively.
6. A priority queue comprising:
- a memory in which elements are stored; and
- a controller which stores the elements in the memory with no memory reads and a constant number of memory writes so a smallest element in the memory can be identified, said controller connected to the memory.
7. A priority queue as described in claim 6 wherein the memory includes a register file having a decision tree and a comparison list.
8. A method for manipulating elements comprising the steps of:
- storing a first element having a value in a first queue location in an element queue having a size which stores 2.sup.N elements, where N.gtoreq.2 and is an integer;
- updating in a register how many elements are in the queue and the value of the first element;
- storing a second element having a value in a second queue location of the element queue contiguously with the first element;
- updating in the register how many elements are in the queue and the value of the second element;
- comparing the value of the second element with the value of the first element to yield a first comparison result corresponding to which value of the first and second elements is larger;
- storing a first comparison result in a first location of a plurality of locations of a decision tree, said plurality of locations corresponding to a plurality of levels;
- updating a first comparison element of a plurality of comparison elements of a comparison list array, each comparison element associated with a level of the plurality of levels, the comparison element updated corresponding to the second queue location of the element queue in which the second element is stored and in the first queue location of the element queue in which the first element is stored;
- storing a third element having a value in a third queue location in the element queue contiguously with the second elements;
- updating in the register how many elements are in the queue and the value of the third element;
- comparing the value of the third element with the value of the first and second elements which is smaller to yield a second comparison result corresponding to which value of the first and second elements and the third element is smaller;
- storing the second comparison result in a second location of the decision tree;
- updating a second comparison element corresponding to the third queue location in which the third element is stored;
- storing a fourth element having a value in a fourth queue location in the element queue contiguously with the third element;
- updating in the register how many elements are in the queue and the value of the fourth element;
- comparing the value of the fourth element with the third element to yield a third comparison result corresponding to which value of the third and fourth elements is smaller;
- storing the third comparison result in a third location of the decision tree;
- comparing the value of the third element and fourth element which is smallest with the value of the first element and second element which is smallest to yield a fourth comparison result corresponding to which value of the first, second, third or fourth elements is smaller;
- storing the fourth comparison result in the second location of the decision tree;
- updating the comparison list;
- changing the value of the third element in the element queue to a new value;
- comparing the new value to the value of the fourth element to yield a fifth comparison result;
- storing the fifth comparison result in the third location of the decision tree;
- comparing the fifth comparison result with the first comparison result of the decision tree to obtain a sixth comparison result;
- storing the sixth comparison result in the second location of the decision tree;
- updating the comparison list;
- finding the queue location in the element queue which has the smallest value by only reading the comparison result in the decision tree; and
- obtaining the smallest value.
4873687 | October 10, 1989 | Breu |
4893302 | January 9, 1990 | Hemmady et al. |
4899333 | February 6, 1990 | Roediger |
4946045 | August 7, 1990 | Ditchburn et al. |
4958341 | September 18, 1990 | Hemmady et al. |
4987539 | January 22, 1991 | Moore et al. |
4989257 | January 29, 1991 | Horowitz |
5130983 | July 14, 1992 | Heffner, III |
- "Lazy Queue: An Efficient Implementation of the Pending-event Set", by Ronngren et al., IEEE, Simulation Symposium, 1991, pp. 194-204. "Zero-One Sorting on the Mesh", by Krizanc et al., IEEE, Parallel and Distributed Processing, 1993 Symposium (5th), pp. 641-647. "Using Difficulty of Prediction to Decrease Computation: Fast Sort, Priority Queue and Convex Hull on Entropy Bounded Inputs", by Chen et al. IEEE, Foundations of Computer Science, 1993 34th Annual Symposium, pp. 104-112. "Sequential decoding of convolutional codes by a compressed multiple queue algorithm", by Kuo et al., IEEE, Proceedings-Communications, vol. 141, No. 4, Aug. 1994, pp. 212-222. "An Implementation of the Generalized Stack Algorithm Using a Partially Sorting Algorithm", by Achtmann et al., IEEE, Singapore ICCS '94, pp. 129-133. "A Heep of Data", by I. Beichl and F. Sullivan, IEEE ComputationalScience & Engineering, Jun. 1996, pp. 11-14.
Type: Grant
Filed: Nov 20, 1995
Date of Patent: Feb 9, 1999
Assignee: FORE Systems, Inc. (Warrendale, PA)
Inventor: Jon C. R. Bennett (Ambridge, PA)
Primary Examiner: Kevin J. Teska
Assistant Examiner: Russell W. Frejd
Attorney: Ansel M. Schwartz
Application Number: 8/559,610
International Classification: G06F 706;