Niklaus Wirth wrote a book that popularised the informal equation used as a title: “Data Structures + Algorithms = Programs”. I like to write this equation backwards as in the title of the question, because it hints at a simple but subtle aspect of programming: we are responsible of deciding which ideas of our programs we want to express by data structures and which we want to express with algorithms.

Is there any hint in the book by Niklaus Wirth that he subscribes to or even expresses this view, or is this free interpretation of the informal equation a mere coincidence?

A classical example would be useful to clarify this point. When we implement a finite state automaton we could represent the state using mutually recursive functions – therefore making the state implicit in our program and giving more weight to the “algorithm” part of our program – or using an explicit variable holding the state – thus arbitraging in favour of data structures. In more advanced example, this choice has sometimes a direct incidence on the maintainability or extensibility of programs.

  • 4
    I haven't the slightest idea what you're asking. However, I can tell you this: in a meaningful computing context, algorithms are worthless without data to process, and raw data is useless without algorithms to process it. So the notion that you might do one without the other seems incomprehensible to me. Commented Mar 17, 2016 at 17:54
  • 1
    state and structure are not the same thing.
    – radarbob
    Commented Mar 17, 2016 at 18:16
  • I do not think I stated anywhere I would like to rely solely on the one or the other! When implementing a program there is a lot of choices to do about which ideas to represent as data and which to represent as code, and often enough one can move one aspect of the program from the code part to the data part. The question is about Wirth expression this view in his book or not. Commented Mar 17, 2016 at 18:20
  • Can you give an example where you would have to choose between an algorithm and a data structure?
    – JeffO
    Commented Mar 17, 2016 at 19:22

1 Answer 1


In the preface to the 2004 edition of Algorithms and Data Structures, Wirth states:

Programs are concrete formulations of abstract algorithms based on particular representations and structures of data... Decisions about structuring data cannot be made without knowledge of the algorithms applied to the data and that, vice versa, the structure and choice of algorithms often depend strongly on the structure of the underlying data. In short, the subjects of program composition and data structures are inseparably interwined.

If I understand your question correctly, then yes, I would read from the preceding paragraph that Wirth acknowledges the fluidity of the boundary between algorithms and data structures, and that where that lies for a particular implementation will be influenced by considerations of performance, maintainability, or other factors.

  • 1
    I never expected to get a precise answer that fast! Thank you. Let's give a grace period for those who would want to write another answer. :) Commented Mar 17, 2016 at 18:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.