Concrete Mathematics: A Foundation for Computer Science (2nd Edition)

Category: Computer Science
Author: Ronald L. Graham, Donald Ervin Knuth, Oren Patashnik
All Stack Overflow 18
This Month Stack Overflow 1


by pmiller2   2020-07-06
I'm going to go a completely different direction from other recommendations and say Concrete Mathematics by Knuth and Patashnik. They will definitely be able to use skills from analysis and calculus here, but there are so many additional tools in this book that it's very much a worthwhile digression. The marginal notes are great, as well!

I own this book, and it's a favorite of mine.

by anonymous   2019-07-21

Concrete Mathematics: A Foundation for Computer Science would be my suggestion for a book that covers some advanced topics.

by anonymous   2019-07-21

My program works for inputs 2, 4, 8, 16, 32, 64 and so on as ans in all these is 1.

This is a good observation. Actually the answer is just a small step from here.

You have n candidates, and you select 1 each time. If n is x + 2^k (with the biggest possible k), after x steps you have 2^k candidates left and the next candidate in the line is the answer. So the answer is 2x+1.

1 2 3 4 5 6 7
  ^   ^   ^ |
   removed  |

Note: This exercise can be found in Concrete Mathematics: Foundation for Computer Science. I highly recommend it.

by randcraw   2018-01-26
Or concrete, as suggested by Knuth, Graham, and Patashnik in their book, "Concrete Mathematics: A Foundation for Computer Science".

by anonymous   2017-08-20

Have a look here: "Is it possible to do modulo of a fraction" on

One natural way to define the modular function is

a (mod b) = a − b ⌊a / b⌋

where ⌊⋅⌋ denotes the floor function. This is the approach used in the influential book Concrete Mathematics by Graham, Knuth, Patashnik.

This will give you 1/2(mod3)=1/2.

To work through your problem, you have a = 7 * (4/11) = 28/11, and b = 10.

a / b = (28/11)/10 = 0.25454545...

⌊a/b⌋ = 0

b ⌊a/b⌋ = 0 * 0 = 0

a - b ⌊a/b⌋ = 28/11 - 0 = 28/11

This means your answer is 28/11.

Wolfram Alpha agrees with me and gives 28/11 as the exact result. Google also agrees, but gives it as a decimal, 2.54545454.....

A fraction is an exact answer and not a decimal.

by kronoz   2017-08-20

I suggest books with good tutorials throughout if you're unable to partake in a maths course. For computer science-related maths Don Knuth's Concrete Mathematics is meant to be very good.

Obviously nothing can replace a good teacher, but good tutorials can come pretty damn close. You really get to learn the subject in the tutorials I think.

by anonymous   2017-08-20

There is a good book, that I think would help you to get more out of computer science research papers and dissertations. It's called "Concrete Mathematics: A foundation for Computer Science", and it's available on Amazon:

I think this would help because it will all be relevant, and its consolidated which will help expedite the learning process.

Even if you don't have any money, just Google it and take a look at the index to get an idea of what areas you might want to learn.

And here's one more interesting book.

by avinassh   2017-08-19
CLRS is quite 'academic' and requires good understanding of mathematics. It's a great book, but not a good one for beginners, imo. It will be difficult as self study for first timers. You can start with Datastructures and Algorithm Analysis in C by M. A. Weiss[0]. One more alternative is The Algorithm Design Manual by S. Skiena[1]. It's also good and focuses more on algorithm, implementation (as opposed to math-y stuff of CLRS). If I were you, I would get both the books and read alternatively. Don't miss out on exercises, they are very important.

I also suggest you to join this Coursera course, Algorithms: Design and Analysis by Tim Roughgarden[2]. Currently the course is open, so you can sign up for classes. The course is offered in two parts[3], complete both of them.

Once you are comfortable with basic concepts start solving questions/puzzles online on sites like SPOJ[4], UVa[5], (YC-funded) HackerRank[6]. You could try TopCoder[7] also, but the questions are bit difficult. Hope this helps.

PS - You should study math, because it is important in Algorithms Analysis. You could try reading required parts of Concrete Mathematics by Knuth[8] or as you come across new concepts, Google and understand them.

[0] -

[1] -

[2] -

by tim_sw   2017-08-19
Has anyone read both this and Knuth's Concrete Mathematics? How do they compare with each other?
by dpflan   2017-08-19
This is always a good topic with numerous HN submissions and comments:

Just from a search, there are some great results:

1. Mathematics for Computer Science - HN Submissions: