r/AskComputerScience • u/BeetrootEnthusiast • Aug 08 '20
Books / resources about thinking robustly about solving problems
I was recently in a job interview in which my interviewer told me that he doesn't believe that university degrees teach many useful things to students. His main point was that they don't do a proper job teaching them to think, and that he has found that even graduate students cannot properly answer problems which he gives them.
I was curious, so I asked him whether he could give me an example of a problem which graduate students can't answer properly. This was the problem:
Given a request, A, with a starting and a finishing time, decide whether it is compatible with another request, B, with a starting and finishing time (two requests are not compatible if their timespans overlap).
My answer was that one can check whether the starting time for request A is after the starting time of request B but before the finishing time of request B, and vice versa for the ending time of request A.
However, he said that my answer was completely wrong. His reason for this was that I jumped straight to solving the problem, instead of proving it beforehand and reasoning about it. When I asked him how he would have answered if he had been asked the problem, his answer was:
The possible cases are that request A may be completely before request B, request A may partially overlap request B on the left, request A may be contained in request B, request B may be contained in request A, request A may partially overlap request B on the right, and request A may be completely after request B.
His explanation for why this is a necessary step of reasoning about a problem was that it allows you to prove that your solution is correct (whereas I, jumping straight to the solution to of the problem, have no way of proving that my solution is correct) and that it is a formal method which allows one to write code which has a lower chance of containing bugs, as you can know that the logic for the code is sound.
From his "proof step" in solving the problem, you can also see quite easily that there is a solution to the problem which requires less computational power than the one I suggested: simply check whether A finishes before B starts or starts after B ends. If this is the case, then they do not overlap.
So my question is whether anyone has any resources or books which they can recommend to me for helping to learn more about how to think about logic before jumping straight to writing the code. I have searched around and haven't yet been able to find anything that great. I'm mostly looking for something practical; i.e. something which only deals with abstract logical proofs and never connects this to how you can use the ideas in your coding would still be something I would be interested in reading, but less so than something which addresses practical application.
Thanks!
TLDR; does anyone have any book or resource recommendations with deal with the idea of how to problem solve and think about logical problems / proofs before actually writing the code.
1
u/UnpaidCommenter Aug 08 '20
I think probability theory is useful for problem solving. Also, there used to be college courses taught on the subject of problem solving. I took a class in problem solving years ago that used the textbook "Patterns of Problem Solving" by Moshe Rubinstein. You may find that book helpful or you could look for the textbooks being used for modern university problem solving classes.
1
u/BeetrootEnthusiast Aug 09 '20
Thanks for the book recommendation. The idea of looking at textbooks used in problem solving classes is actually a great idea I had not thought of yet - I've followed similar search terms of google and have looked for logic books for programmers, etc, but not exactly that. I'll give it a shot, thanks for the idea.
1
u/UnpaidCommenter Aug 11 '20
I was curious to see if I could find books similar to Rubintein's. This one seems like it might be good: "Think Like a Programmer: An Introduction to Creative Problem Solving" by V. Anton Spraul
1
2
u/thehellnokitty Aug 08 '20 edited Aug 08 '20
Great ask! made me think about the importance of proofs for writing less buggy code.
Although I do not know of any books for such things, I found solving problems on sites like leetcode and hackerrank made me at least slightly better at writing logic this way.
1
2
u/Kuais Aug 08 '20
You should try competitive programming. I'd recommend using sites like Codeforces or AtCoder as they have editorials for most of their problems and they usually have some edge cases for their problems. Typically the questions are much harder than those you may find in an interview but they sure help stimulate your problem solving and critical thinking abilities.
1
u/m_domino Aug 08 '20
So he didn’t mention the possible case that A and B overlap entirely? (Not that this would change the Solution)
2
Aug 08 '20
that case belongs A is contained in B and B is contained in A cases. In fact, their intersection.
0
Aug 08 '20
[deleted]
1
u/BeetrootEnthusiast Aug 08 '20
That was actually one of the optional textbooks for my algorithms class earlier this year, so I've already read a few parts of it. My thoughts were that it was mostly a book which introduces you to many different algorithms and assists a bit in your devising of solutions for them, but that it mostly doesn't cover the area of helping one to think about the problem in a structured way before even starting on the solution? Thanks for the suggestion though, I'll be sure to give it another look!
0
Aug 08 '20
[deleted]
1
u/BeetrootEnthusiast Aug 09 '20
When you say that the book derived a handful of theorems that you could rely on to prove harder problems, would you say that there are specific sections of the book which do this clearly? As I said, I haven't read the whole book yet - although from your comments I will give it another look over - and, if you can remember which sections are relevant, it would be nice if there was a part I could jump to so that I can see if the book is what I'm looking for. Obviously I'm not expecting you to do this just for me and I'll give it a look anyway, but if you can remember or have the index easily on hand I would appreciate that :)
0
16
u/fallen_lights Aug 08 '20
First of all, great job for taking it like a champ! Some people would take that kind of feedback negatively.
I recommend 2 books:
How To Solve It (Pòlya)
The Algorithm Design Manual (Skiena)
The problem you mentioned is in the first 20 pages of Skiena