It can be exhausting chasing the next AMAZING new thing: NEW language, NEW framework, NEW platform, NEW device. Classic Computer Science Problems in Swift invites you to invest your energy in some foundational techniques that have been proven to stand the test of time. This engaging, imminently-practical book teaches you to recognize and solve the most common categories of problems you'll face as a programmer, including search, clustering, and even AI. Working through the easily digested examples in every chapter, you'll get hands-on practice that will serve you well in app development, optimization, and tool building. Along the way you'll learn intermediate and advanced features of the Swift programming language, a worthwhile skill in its own right.
"Fun read to sharpen your Swift programming skills. Great book to bring your Swift programming to another level."
~ Becky Huett
"I would say that every programming language needs an author to write a book like this."
~ Patrick Regan
0.1 Why Swift?
0.2 What is a classic computer science problem?
0.3 Who is this book for?
0.4 Swift Versioning and Tools
0.5 No Graphics, No UI Code
1 Small Problems
1.1 The Fibonacci Sequence
1.1.1 A First Recursive Attempt
1.1.2 Utilizing Base Cases
1.1.3 Memoization to the Rescue
1.1.4 Keep it Simple, Fibonacci
1.2 The Knapsack Problem
1.3 Unbreakable Encryption
1.3.1 Getting Our Data in Order
1.3.2 Encrypting and Decrypting
1.4 Calculating Pi
1.5 The Towers of Hanoi
1.5.1 Modeling the Towers
1.5.2 Solving The Towers of Hanoi
1.6 Real World Applications
2 Search Problems
2.1 DNA Search
2.1.1 Storing DNA
2.1.2 Linear Search
2.1.3 Binary Search
2.1.4 A Generic Example
2.2 Maze Solving
2.2.1 Generating a Random Maze
2.2.2 Miscellaneous Maze Minutiae
2.2.3 Depth-First Search
2.2.4 Breadth-First Search
2.2.5 A* Search
2.3 Missionaries and Cannibals
2.3.1 Representing the Problem
2.4 Real World Applications
3 Constraint Satisfaction Problems
3.1 Building a Constraint Satisfaction Problem Framework
3.2 The Australian Map Coloring Problem
3.3 The Eight Queens Problem
3.4 Word Search
3.6 Circuit Board Layout
3.7 Real World Applications
4 Graph Problems
5 Genetic Algorithms
6 K-Means Clustering
7 Fairly Simple Neural Networks
8 Miscellaneous Problems
Appendix A: A Glossary
Appendix B: B Further Resources
About the Technology
Apple's Swift language is the de-facto standard for iOS and Mac development, and it's rapidly becoming a great choice for any general-purpose programming task. Swift empowers you to use Object-oriented, Protocol-oriented, and Functional approaches to development, meaning you can choose the best programming style for the task without switching languages mid-stream. By exploring these classic computer science problems in Swift, you'll deepen your skill as a programmer and also discover the breadth of the fantastic Swift language in way that's far more interesting and engaging than the typical language reference.
- Search algorithms including breadth-first search, depth-first search, and A*
- Constraints satisfaction problems
- Common techniques for solving graph problems
- Implementing genetic algorithms
- K-means clustering
- Simple neural networks
About the reader
Written for developers comfortable with the basics of Swift and interested in learning proven problem-solving techniques, deepening their knowledge of computer science, or preparing for coding interviews, while expanding their Swift skillset.