Skip to main content

Some modified algorithms for Dijkstra's longest upsequence problem


Using the techniques of “specification and transformation by parts”, algorithms are derived for the longest upsequence problem. First Dijkstra's algorithm and then two new modified merge algorithms are derived and presented in detail. The merge algorithms take advantage of natural runs in the input sequence and have a worst caseO(n logn) time complexity when appropriate merging techniques are used, but can be linear if long runs are present in the sequence. The first merge algorithm is logically equivalent to Dijkstra's algorithm; the second algorithm is based on the first one but uses a different merging technique. Expository remarks describe related results which evolved out of our work in programming by transformation; in particular, parallels are drawn between algorithms for the longest upsequence problem and algorithms for sorting.

This is a preview of subscription content, access via your institution.


  1. 1.

    Dijkstra, E.W.: Some beautiful arguments using mathematical induction. Acta Informat.13, 1–8 (1980)

    Google Scholar 

  2. 2.

    Dewar, R.B.K., Merritt, S.M.: A derivation of sorting algorithms (to be published)

  3. 3.

    Dewar, R.B.K., Schonberg, E.: The elements ofSETL style. Proc. ACM Conf., Detroit 1979

  4. 4.

    Dewar, R.B.K., Schonberg, E., Schwartz, J.T.: Higher level programming. CIMS, New York University 1981

  5. 5.

    Green, C., Barstow, D.R.: On program synthesis knowledge. Artifical Intelligence10, 241–279 (1978

    Google Scholar 

  6. 6.

    Hwang, F.K., Lin, S.: A simple algorithm for merging two disjoint linearly ordered sets. SIAM J. Computing1, 31–39 1972

    Google Scholar 

  7. 7.

    Knuth, D.E.: The art of computer programming, Vol. III: Sorting and searching. Addison-Wesley, Reading, MA, USA, 1973

    Google Scholar 

  8. 8.

    Manacher, G.K.: Significant improvements to the Hwang-Lin merging algorithm. JACM26, 3, 434–440 (1979)

    Google Scholar 

  9. 9.

    Manacher, G.K.: The Ford Johnson Sorting Algorithm is not optimal. JACM26, 3, 441–456 (1979)

    Google Scholar 

  10. 10.

    Merritt, S.M.: The role of the high level specification in programming by transformation: Specification and transformation by parts. Ph.D. Thesis, Computer Science Dept. New York University, 1982

  11. 11.

    Schwartz, J.T.: On programming: An interim report on theSETL project. CIMS, New York University, 1974

  12. 12.

    Sharir, M.: Some observations concerning formal differentiation of set-theoretic expressions. ACM TOPLAS4, 2, 196–225 (1982)

    Google Scholar 

Download references

Author information



Additional information

Work on this paper has been supported in part by: ONR Grant N00014-75-C-0571; NSF Grant MCS-80-04349; USDOE Contract EY-76-C-02-3077

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Dewar, R.B.K., Merritt, S.M. & Sharir, M. Some modified algorithms for Dijkstra's longest upsequence problem. Acta Informatica 18, 1–15 (1982).

Download citation


  • Information System
  • Operating System
  • Data Structure
  • Communication Network
  • Information Theory