Prefácio

Este é um curso introdutório de projeto de algoritmos e estruturas de dados básicas.  Os algoritmos são escritos em C;  é preciso que o leitor tenha alguma familiaridade com essa linguagem de programação.

Eu tenho usado estas notas de aula nas disciplinas MAC0122 (Princípios de Desenvolvimento de Algoritmos) e MAC0121 (Algoritmos e Estruturas de Dados I) no Instituto de Matemática e Estatística da USP.   Essas disciplinas são obrigatóriasx no currículo do Bacharelado em Ciência da Computação do IME (Instituto de Matemática e Estatística) da USP (Universidade de São Paulo).

 


Dijkstra e o ensino de computação e programação

Informatica gaat net zo min over computers
als astronomie over telescopen.

Computer science is no more about computers
than astronomy is about telescopes.

— Edsger W. Dijkstra

Edsger W. Dijkstra tinha opiniões firmes e originais sobre o ensino de programação e de computação. Acho que é apropriado citar aqui alguns trechos do seu manuscrito EWD1036 On the cruelty of really teaching computing science  (eu enfatizei algumas frases):

So, if I look into my foggy crystal ball at the future of computing science education, I overwhelmingly see the depressing picture of 'Business as usual'. The universities will continue to lack the courage to teach hard science, they will continue to misguide the students, and each next stage of infantilization of the curriculum will be hailed as educational progress.

We could, for instance, begin with cleaning up our language by no longer calling a bug a bug but by calling it an error. It is much more honest because it squarely puts the blame where it belongs, viz. with the programmer who made the error. The animistic metaphor of the bug that maliciously sneaked in while the programmer was not looking is intellectually dishonest as it disguises that the error is the programmer's own creation. The nice thing of this simple change of vocabulary is that it has such a profound effect: while, before, a program with only one bug used to be 'almost correct', afterwards a program with an error is just 'wrong'.

The statement that a given program meets a certain specification amounts to a statement about all computations that could take place under control of that given program. And since this set of computations is defined by the given program, [we must] deal with all computations possible under control of a given program by ignoring them and working with the program.  We must learn to work with program texts while (temporarily) ignoring that they admit the interpretation of executable code.

Needless to say that, all by itself, a program is no more than half a conjecture. The other half of the conjecture is the functional specification the program is supposed to satisfy. The programmer's task is to present such complete conjectures as proven theorems.

Right from the beginning, and all through the [introductory programming] course, we [should] stress that the programmer's task is not just to write down a program, but that his main task is to give a formal proof that the program he proposes meets the equally formal functional specification.  [...]  Finally, in order to drive home the message that this introductory programming course is primarily a course in formal mathematics, we see to it that the programming language in question has not been implemented on campus so that students are protected from the temptation to test their programs. And this concludes the sketch of my proposal for an introductory programming course for freshmen.

E. W. Dijkstra Archive
coleção de manuscritos de Edsger W. Dijkstra