Skip to main content
Log in

Stable duplicate-key extraction with optimal time and space bounds

  • Published:
Acta Informatica Aims and scope Submit manuscript

Summary

We consider the problem of transforming a list L of records sorted on some key into two sublists L 1 and L 2 where, for each distinct key in L, L 1 contains the first record of L that possesses the key and L 2 contains all records of L with duplicate keys. We desire that our duplicate-key extraction algorithm perform the transformation in place and be stable (that is, records within each sublist must obey the original order given by L). This operation is useful in database and related file processing environments whenever only distinct keys need be considered. Moreover, stability in extraction insures that L can be efficiently restored at a later time with a stable merge of L 1 and L 2. Any procedure for performing duplicate-key extraction on a list of size n must require at least O(n) time and O(1) extra space, although the obvious algorithm for achieving either bound alone violates the other bound. We design a stable algorithm, using block-rearrangement techniques, and show that it is optimal in the theoretical sense that it achieves both lower bounds simultaneously. We also prove that its worst-case number of key comparisons and record exchanges sum to no more than 6 n, suggesting that the algorithm has practical application as well.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Huang, B.-C, Langston, M.A.: Stable Duplicate-Key Extraction with Optimal Time and Space Bounds. Proc. 24th Allerton Conf. Commun. Control Comput., pp. 288–295, 1986

  2. Huang, B.-C., Langston, M.A.: Practical In-Place Merging. Commun. ACM 31, 348–352 (1988)

    Google Scholar 

  3. Huang, B.-C., Langston, M.A.: Stable Set and Multiset Operations in Optimal Time and Space. Proc. 7th ACM Symp. Principles Database Syst. pp. 288–293, 1988

  4. Huang, B.-C., Langston, M.A.: Fast Stable Merging and Sorting in Constant Extra Space. Computer Science Department Technical Report CS-87-170, Washington State University, 1987

  5. Horvath, E.C.: Stable Sorting in Asymptotically Optimal Time and Extra Space. J. ACM 25, 177–199 (1978)

    Google Scholar 

  6. Knuth, D.E.: The Art of Computer Programming, Vol. 3: Sorting and Searching. Reading, MA: Addison-Wesley 1973

    Google Scholar 

  7. Kronrod, M.A.: An Optimal Ordering Algorithm Without a Field of Operation. Dok. Akad, Nauk SSSR 186, 1256–1258 (1969)

    Google Scholar 

  8. Mannila, H., Ukkonen, E.: A Simple Linear-Time Algorithm for In Situ Merging. Inf. Proc. Lett. 18, 203–208 (1984)

    Google Scholar 

  9. Salowe, J.S., Steiger, W.L.: Stable Unmerging in Linear Time and Constant Space. Computer Science Department Technical Report, Rutgers University, 1985

  10. Salowe, J.S., Steiger, W.L.: Simplified Stable Merging Tasks. J. Algorithms 8, 557–571 (1987)

    Google Scholar 

  11. Trabb Pardo, L.: Stable Sorting and Merging with Optimal Space and Time Bounds. SIAM J. Comput. 6, 351–372 (1977)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Additional information

This author's research has been supported in part by the Washington State University Graduate Research Assistantship Program

This author's research has been supported in part by the National Science Foundation under grants ECS-8403859 and MIP-8603879, and by the Office of Naval Research under contract N0001488-K-0343

Rights and permissions

Reprints and permissions

About this article

Cite this article

Huang, B.C., Langston, M.A. Stable duplicate-key extraction with optimal time and space bounds. Acta Informatica 26, 473–484 (1989). https://doi.org/10.1007/BF00289147

Download citation

  • Received:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF00289147

Keywords

Navigation