Wednesday, October 30, 2013

Writing a programming / algorithmic book

I wanted to take on a new challenge and start writing a book about algorithms and design. The intent is to have Simplicity by Design (SD): every Chapter is a collection of 15-30 questions, followed by the solution, followed by a C++ code snippet which can be easily re-used.

So far, I have drafts for 3 chapters: bit programming, dynamic programming, and graphs. Here an example of graph code with very classical questions: implement a graph, implement bfs, implement dfs, implement topological sort, I already have code for other graph problems.  Dynamic programming has more mathematical content and I will publish an excerpt next weeks.

A number of questions:

  1. Should I publish code for public review? If so, can i still use it for the book?
  2. Should I publish questions for public review?
I think that this will be one of my side projects off work for the next year or so.


  1. 1a) Yes. 1b) My question is: why not? If your concern is about earning money from book royalties that include material you haven't written/created without distributing those earnings, there are several successfull precendents. Use a clear and transparent license for the code, keep trace of the input of the public review and put proper reference of those people in the book text. Authors have their rewading, Reviewers earns citation points. At least someone will be happy.

    2. Yes. Some questions from reviewers will puzzle you, some others will delight you, some will be valuable for the readers. You write the book for the reader (even if someone don't think so). Is a no-question to me.

  2. I would go opensource, build the book similar to: Generate donations on the project site to help offset any costs and/or distribute amongst the core contributors.