Classic Computer Science Problems in Java

Author: David Kopec
Publisher: Manning
Date: January 2021
Pages: 264
ISBN: 978-1617297601
Print: 1617297607
Audience: Java developers
Rating: 4
Reviewer: Mike James
Getting someone else to do the hard work of converting classic problems to code seems like a good idea. It all depends which problems and which code.

In this case the code is Java and of course if you aren't a Java programmer this isn't going to be of much use to you. The good news is that at the time of writing there is a Swift and a Python version, which although I haven't read them are presumably much the same as this book only in a different language.

Banner

The first thing to say is that some of the "classic" algorithms are very simple and they are even announced as "small problems" in Chapter 1. The first algorithm in the book is the Fibonacci sequence and this is implemented using recursion, which is a bit of a barrier to put at the very start of any book. Even so, as long as you don't lose confidence, it is easy enough. I'm not sure I'd call it a classic algorithm, however it is a very common example. The implementation is also elaborated to include memoization, which either is or isn't part of a classic algorithm depending on your point of view. Memoization is about efficiency and hence isn't really an issue if you are considering theoretical algorithms, but it is a basic technique to make almost anything go faster. I'd rather not see it introduced in this confusing position. After all this sophistication we have a final iterative version - perhaps this would be better presented first? The rest of the chapter details a simple encoding/decoding problem, calculating Pi using the easy, but slow to converge, series and the Towers of Hanoi problem. I don't really think any of these are classic algorithms in the computer science sense, but they are all commonly used as examples.

Chapter 2 is about search, which is a classic problem, but the solutions presented are the usual computer science approach of linear search, binary search and so on wrapped up in a problem involving searching DNA. From here we have depth first and breadth first search and A*.

Chapter 3 is about constraint satisfaction, which is not a mainstream "classical" problem, but we do meet the eight queens problem which is.  This is essentially about backtracking search.

 

Chapter 4 moves on to consider graph algorithms. Here we meet some classic algorithms - Minimum Spanning Tree and Dijkstra's algorithm. Chapter 5 is about genetic algorithms, which I do not think of as classic problems or even classic algorithms, interesting though they are. The same goes for Chapter 6 and the K-means clustering algorithm. As far as I'm concerned K-means is just one a set of possible clustering algorithms.

Chapter 7 continues with a look a neural networks and, for me, nothing could be further from a classic problem. It covers back-propagation and goes fairly deeply into basic neural networks. Chapter 8, called Adversarial Search, it is still more connected to AI than anything else. The examples are tic-tac-toe and Connect Four and the algorithms are mini-max and alpha-beta pruning. Classics of AI indeed.

The final "proper" chapter, Chapter 9, is on the knapsack problem and the travelling salesman problem, with a brief introduction to NP problems. Chapter 10 is an interview with Brian Goetz who is well known in the Java world and, while the interview is interesting, I'm not at all sure why it is included in the book. The focus of the book is using Java to solve some well-known problems rather than Java as a language.

This book might well not be what some portential readers are expecting? I'm not sure that the selection of problems is what a majority of computer scientists would consider "classic". but this is a matter of opinion. There are a lot of AI-oriented algorithms included and this pulls the book's focus away from what many would consider mainstream Computer Science. The biggest ommission are the sorting algorithms, which arguably are the starting point for all accounts of classical computer science algorithms. Also there are no data structure algorithms - linked lists, stacks, trees etc. If you do want to stray from pure computer science then what about the Fast Fourier Transform? All good candidates for a classic problem book.

What all this means is that this book isn't going to be of much use to anyone hoping for some help with a computer science course. Its idea of classic algorithms is too patchy and too biased to be of much help. The introduction to the book does state very clearly that it isn't an academic tome covering big O analysis etc, but even so the choice of algorithms doesn't fit with its title.

Having said this the algorithms are that are described are well presented and it is a slim book and so you can't really expect it to cover everything. So the bottom line is that if the selection of problems interests you, then why not give it a try? What it does do is done well.

 

For recommendations of books covering Algorithms see Top Computing Theory Book Choices in our Programmers Bookshelf section

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Mathematics for Machine Learning

Authors: Marc Peter Deisenroth, Aldo Faisal and Cheng Soon Ong
Publisher: Cambridge University Press
Pages: 398
ISBN: 978-1108455145
Print: 110845514X
Kindle: B083M7DBP6
Audience: Developers interested in machine learning
Rating: 3.5
Reviewer: Mike James
Lots of people need to learn the math behind mach [ ... ]



Programmed Inequality

Author: Marie Hicks
Publisher: MIT Press
Pages: 352
ISBN:  978-0262535182
Print: 0262535181
Kindle: B01MV05ABA
Audience: General interest
Rating: 4.5
Reviewer: Sue Gee

Subtitled "How Britain Discarded Women Technologists and Lost Its Edge in Computing" this sounds like a fasci [ ... ]


More Reviews

Last Updated ( Wednesday, 01 September 2021 )