Jump to ratings and reviews
Rate this book

Classic Computer Science Problems in Python

Rate this book

224 pages, Paperback

Published March 15, 2019

Loading interface...
Loading interface...

About the author

David Kopec

15 books14 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
16 (21%)
4 stars
26 (35%)
3 stars
27 (36%)
2 stars
3 (4%)
1 star
1 (1%)
Displaying 1 - 18 of 18 reviews
Profile Image for Daniel van Dorp.
4 reviews2 followers
February 9, 2021
I like to manage expectations first in my reviews, so let's start with what this book requires: it is for intermediate Python programmers as mentioned briefly on the back of the book, and it covers Python 3.7 (2018-06). The book improves your problem-solving skills by presenting you with various types of challenges including, but not limited to, Small problems, Search problems, Constraint-satisfaction problems, Graph problems, Genetic algorithms, K-means clustering, Fairly simple neural networks, Adversarial search and Miscellaneous problems. Solving these provides you with a true feeling of satisfaction and it also provides you with a feeling of improved self-confidence for eg. a job interview.

The language of the book is refreshing and assuming you already have intermediate Python knowledge and thus are fairly proficient in reading as well as writing it, it helps you understand modern-day practical computer science quite well. Chapters seem to be ordered in a way of increasing difficulty, allowing you to grow your brain-crunching skills throughout the book itself as well. What I really like about the book is that each chapter starts with a brief introduction on practical context of the problems and how it can help society, that differs sharply from educational (math) textbooks trying to explain similar challenges. K-means clustering, neural networks and adversarial search were some of the more challenging chapters for me, but I have enjoyed all of them. In the last chapter it touches the most classical examples such as the knapsack problem (NP-complete) and Traveling Salesman problem (NP-hard) as well, which are famous for appearing simple.
12 reviews8 followers
April 30, 2019
This is a book I really wish to like more but there's a lot of problems preventing that.

- The Python type system is cumbersome. Really cumbersome in a way that you care more about some TypeVar("T") than the problem itself. So there's a lot of type hinting and amazing things you can do with python 3.6+ but after some time you forget the 'classic problems' part.
- A lot of problems do not have test cases, nor a 'main()' function to test it (some are asked in exercises but still I don't think this is the right approach)
- The 'framework' idea of solving problems (showing that a lot of problems have the same structure) is really good but still, the focus here is not the problems. Big problems in computer science like Knapsack and Dynamic Programming are implemented but without real explanation what it's going on.
- I think this is a book for people who already know computer science and serves as a 'bad reminder'
Profile Image for Henrik Warne.
219 reviews37 followers
October 27, 2019
I really liked Classic Computer Science Problems in Python. It covers many interesting algorithms, several of which I had not read about before. My favorites in the book were neural networks, constraint-satisfaction problems, genetic algorithms, and the minimax algorithm.

For most of the algorithms, the author develops a framework solution, and then uses it to solve a few different problems of the same kind. The solutions are complete but small programs that you can download from GitHub. They are well suited for exploring the solutions in more detail. For example, I used the neural network program to see how the neuron weights varied between different runs.

I found this to be one of the better algorithm books that I have read. I have written a more detailed review on my blog at:
9 reviews1 follower
June 28, 2020
This was a great idea for a book. It compiles a lot of the CS problems you encounter in college and summarizes them succinctly. Understanding the problems and how they are solved will make you a better coder and also prepare you for interviews. Plus, they are interesting on their own.

I also like the author's writing style. This is the first Manning book I've purchased and it reminds me a lot of the No Starch Press books, that is, there was a lot of thought, effort, and editing put into the book and you can see it on every page.

This book is for more advanced Python users, and you will learn a lot about optimization and writing efficient code, something the beginner books tend to skip for readability. The author also uses type annotations, which take some getting used to but are good to know as they will probably become commonplace in a few years, so you might as well learn them now.

I started learning new things on page one, and had to work hard because this is a somewhat advanced book, but I appreciated the workout. I'm pleased with this purchase and hope to see more books by David Kopec in the future.
Profile Image for Tom Dopirak.
38 reviews
April 13, 2020
Who reads the directions anymore? Oh yeah it says intermediate Python programmer in the fine print. Let me try it anyway. Oh dear what does that notation mean? Oh it's advisory for features the interpreter hasn't implemented yet or things that are only explained on python.org.

That aside the book was very useful for somebody that kind of knew python at the 3rd grade level and hasn't had a data structures course in 40 years. I am glad I bought it and recommend it to anyone with the will to learn the material. I read half of it while sitting in my car in the Walmart parking lot waiting for my wife to return from grocery shopping. It was situationally riveting!
Profile Image for Jeff.
1 review
January 22, 2020
This is a fantastic primer on some selected fundamental topics in computer science including k means clustering, adversarial search, and artificial neural networks. Follow along with an IDE open and work through the wonderful examples in this book to get the maximum value from the material.
Profile Image for Chris Esposo.
671 reviews31 followers
July 27, 2020
This is a good alternative introduction to computing with a more modern, intelligence-focused twist (appropriate to the times), and centered less on textbook content/commentary/analysis and more on understanding computing a problem solving paradigm via key folklore problems that propel the instruction and simultaneously skills-build. In this respect, the book can easily be added in a required reading for class, perhaps appropriate for a first or second generalist introduction to computer science, attempted prior to taking a formal algorithms course. Also, the book is a great quick refresher/skill-builder for professionals who operate in computing, either as a SWE or Data Scientist (though I suspect much of the first few chapters would be too trivial for a seasoned SWE) .

The first chapter mostly introduces tried-and-true topics from classical computing focusing on sorting and search problems. Without being too reductionist, almost all things in computing are motivated or can be contextualized as a sorting/search procedure, similar to the fact that machine learning can mostly be understood as procedures for weight allocation. Thus, the choice of topics, and the associated material/exercises is definitely appropriate. Each subsequent chapter gets closer to the notions important to modern data science/machine learning, with constraint and optimization. After the motivating exposition and associated folklore challenge, there’s usually a handful of functions specified in python, with exposition explaining the mechanics of the code. The level of structure of these snippets tend to be a bit beyond “script level” code, with formal classes defined, and care taken to understand type and process.

Following the clustering section, we hit problems on graphs, and here we see the code get a bit more terse as recursion is freely leveraged in the logic of the functions/code. Though this elevation in abstraction is gradual, with the topic of imperative programming well introduced in the first chapter of the book, with much of the early code being written with the explicit loop structure outlined. The topics covered here, mostly revolving around scheduling, and travelling-salesman like challenges are appropriate and insightful for the level of instruction.

The next few topics are firmly within the domain of machine learning/data science, which includes clustering and a “ground-up” construction of artificial neural networks. These sections were especially interesting, and should be enjoyable for readers looking to get their hands dirty with respect to leveraging these skills in real-life data problems. The remaining chapters focus on misc. Problems in computing.

Overall, I enjoyed the book, but because I have not completed all of the exercises, can’t provide a full review of the text. However, having purchased both the Kindle and audiobook, I can say that I am impressed with the material, and although it may be viewed as too elementary for older hands, I found myself getting morsels of information/new insights/refinements within the exposition. Thus, for me, the text was useful.

Beside students and practitioners looking for some mental exercise/review, I also believe this text could be used as a supplemental resource for interview prepping, especially in roles that may have more software engineering elements, like a machine learning or AI engineering role. Whatever your use-case, I feel that this book is a worthy read, especially if purchased at discount. Recommended, though will provide an update to this review upon completion of more of the exercises and further meditations on the material.
6 reviews1 follower
March 16, 2020
I would recommend this book for someone who has either a recent CS degree XOR a solid Python understanding.

Any combination of the two means this book doesnt have a lot to offer for you.

Other than that it is well written and friendly, I would imagine it could be a good refresher for someone who graduated from CS >10 years ago.

Profile Image for Dmitri S.
167 reviews4 followers
February 4, 2020
Читал в переводе издательства «Питер», к которому — что бывает редко с технической литературой на русском — нет вообще никаких претензий, кроме, конечно, выбора исходного материала.

Единственное хорошее, что я нашел в этой книге — это отсылки к другим, явно более качественным источникам. Исходя из предположения, что автор их тоже читал, сложно не задаваться вопросом — зачем и для кого была написана эта книга, процентов на 80% идущая внахлест с «Grokking Algorithms»? Сам автор в предисловии упоминает, что «аудитория этой книги — программисты среднего и высокого уровня», после чего он будет на протяжении 200 страниц рассказывать о том, как работает рекурсия и поиск вглубину, что такое дерево, как написать игру в крестики-нолики и всё тако�� прочее с 101-лекций. При этом, все эти темы, давно забытые обозначенной аудиторией, как правило, сопровождаются кодом, который проще написать с нуля, чем понять. Так фундаментально, например, у Копеца ��ачинается модуль реализации алгоритма Дейкстры:

from future import annotations
from typing import TypeVar, List, Optional, Tuple, Dict
from dataclasses import dataclass
from mst import WeightedPath, print_weighted_path
from weighted_graph import WeightedGraph
from weighted_edge import WeightedEdge
from priority_queue import PriorityQueue

…и продолжается далее всей красотой декораторов и классов питона. На вопрос «почему?» автор не отвечает, но очевидно, что — потому что может.

При всём этом книга прикидывается дружеским справочником, который можно открыть с любого места и познакомиться с каким-нибудь новым алгоритмом. И в это же время код написан так, будто предполагается, что читатель готов не только с первой страницы держать в голове весь написанный автором код, но и где-то даже предвидеть, для каких задач этот код планируется использовать в последующих главах. Сам автор, конечно, знает, что через 50 страниц этот модуль будет импортироваться для другой задачи, а читателю остается только верить и ждать, что алгоритм (который можно реализавать в две простых функции) нужно расписывать простыней классов и зависимостей. Автор настолько увлечен идеей написания универсального кода, который можно переиспользовать для решения разных задач схожего подхода, что будто бы немного забывает рассказать про заявленную тему книги — задачи и алгоритмы.

В дополнение, в этой книге не было ни одной темы, по которой первая же выдача гугла не давала более грамотное и понятное объяснение. А в случае с некоторыми алгоритмами, иногда даже одна блок-схема из википедии давала лучшее объяснение, чем 20-страничная гла��а книги. Даже имея полное представление о раскрываемой автором теме иногда приходилось по паре минут буксовать над одним абзацем, только чтобы въехать в его авторские аналогии. До последней страницы книги не покидало ощущение того, что от самых первых набросков и до печати этот текст не касался ни одного человека имеющего хоть какое-нибудь отношение к образованию; и также, что автор явно любит писать свой код сильно больше, чем учить. Такой вот молодец.

2/10. Книга будет бесполезна/вредна для начинающих и предельно скучна для всех остальных.
Profile Image for Joe Born.
45 reviews
April 13, 2022
I’ve played around considerably with neural networks (as a student) and used TensorFlow to implement them, but it was really cool to see one implemented entirely in Python. It allowed me to play around and inspect the neurons and weights, etc. That was a really helpful set of exercises to not just “learn” about them, but to actually watch one in action.

With this book, you get an active community and an author who actively participates in that community, so lots of support! Highly recommended as a way to easily get hands-on with a variety of fundamental algorithms. Wish I had read this book before I dove into Russell's AI book, since so many of the building blocks are well articulated here.
310 reviews1 follower
July 31, 2021
Definitely not yet another data structures and algorithms in X language book. However, despite the fact the book is really well written and holds together nicely I struggled with it. I'm finding it kind of hard to nail who the target audience is, novice would be a bit lost as there is rather little build-up / help with getting into a sort of algorithmic thinking mindset (e.g. problems like this can be solved with algorithm / data structure like that). Maybe, I just got spoiled by so many other good algorithmic books, but that's what I'd find missing just starting with the subject. On the other hand if I have already a passing knowledge of CS (here, bonus points for stretching the book into basic neural networks and adversarial search) and are looking into getting your Python into next level, then my intuition tells me that too much is coded form scratch (for educational purposes I guess). I wouldn't say it's not idiomatic Python (as if I knew, mainly reading the code, rarely writing any in Python ;-)), but I just miss real-world examples of libraries, frameworks that you would put to work.
Anyhow, a nice book, not too boring, worth picking up if you misplaced your Grokking Algorithms An Illustrated Guide For Programmers and Other Curious People or whatever algorithmic reference you are using these days (actually, if you are actually reading it, would you mind sharing what that would be? cheers)
Profile Image for Lucas Bleme.
8 reviews
May 16, 2020
Some of the most important CS problems are explained in a very simplified manner (mainly search related stuff such as DFS, BFS and a star). Some of them require a more formal definition with better diagrams and data structure analogies.
Profile Image for  Maksim.
113 reviews3 followers
March 7, 2021
Прогадал с уровнем. Для новичков должно быть в самый раз.
Profile Image for bimri.
Author 2 books6 followers
December 30, 2021
When I see heavy use of `Type hinting` in Python - the code becomes an eyesore! That part of this text really pissed me off, nonetheless its a fantastic book to work out those infamous CS problems!
Profile Image for Joe.
378 reviews15 followers
July 17, 2019
Good review for someone who already knows the basics of Python and computer programming. I encountered a few problems that I hadn't seen before, but after I read them I thought, "Oh, I can see why these are important computer problems." There are even some data science algorithms in here (K-means clustering, neural networks).
Displaying 1 - 18 of 18 reviews

Can't find what you're looking for?

Get help and learn more about the design.