Common student exercises in computer science
From Citizendium, the Citizens' Compendium
- Hello World
- Write one of the smallest possible programs printing "Hello World" on the screen. Simple problem to show syntax.
- Eight queens problem
- Arrange eight queens on a chess board so that none can capture the others. The implementation of this problem uses recursion and backtracking.
- Dining philosophers problem
- Five philosophers want to eat spaghetti with five forks but each one needs two of them. Shows the concepts of deadlock and starvation(!).
- Byzantine generals problems
- A number of locally distributed byzantine generals try to reach a consensus on when to attack a superior enemy. But there are traitors amongst them. Demonstrates failure scenarios where fault tolerance becomes difficult.
- Is a square a rectangle?
- Most object-oriented programming languages just say "No"! Example used to explain why combining inheritance and specialization relationships into the subclass relationship might not have been such a good idea after all.