Classic Computer Science Problems in Swift
Essential techniques for practicing programmers
David Kopec
  • March 2018
  • ISBN 9781617294891
  • 224 pages
  • printed in black & white

A fun read to sharpen your classic programming skills and to bring your Swift programming to another level.

Becky Huett, Big Shovel Labs

Classic Computer Science Problems in Swift deepens your Swift language skills by exploring foundational coding techniques and algorithms. As you work through examples in search, clustering, graphs, and more, you'll remember important things you've forgotten and discover classic solutions to your "new" problems. All examples are written in Swift 4.1.

Table of Contents detailed table of contents

Introduction

0.1 Why Swift?

0.2 What is a classic computer science problem?

0.3 What kinds of problems are in this book?

0.4 Who is this book for?

0.5 Swift Versioning and Tools

0.6 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 Trivial Compression

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

1.7 Exercises

2 Search Problems

2.1.1 Storing DNA

2.1.4 A Generic Example

2.2 Maze Solving

2.2.1 Generating a Random Maze

2.2.2 Miscellaneous Maze Minutiae

2.3 Missionaries and Cannibals

2.3.1 Representing the Problem

2.3.2 Solving

2.4 Real World Applications

2.5 Exercises

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.5 SEND+MORE=MONEY

3.6 Circuit Board Layout

3.7 Real World Applications

3.8 Exercises

4 Graph Problems

4.1 Building a Graph Framework

4.1.1 A Concrete Implementation of Edge

4.1.2 A Concrete Implementation of Graph

4.2 Finding the Shortest Path

4.2.1 Defining a Path

4.2.2 Revisiting Breadth-First Search (BFS)

4.3 Minimizing the Cost of Building the Network

4.3.1 Workings with Weights

4.3.2 Finding the Minimum Spanning Tree

4.4 Finding Shortest Paths in a Weighted Graph

4.4.1 Dijkstra’s Algorithm

4.5 Real World Applications

4.6 Exercises

5 Genetic Algorithms

5.1 Preliminaries

5.2 A Generic Genetic Algorithm

5.3 A Naive Test

5.4 SEND+MORE=MONEY Revisited

5.5 Challenges for Genetic Algorithms

5.6 Real World Applications

5.7 Exercises

6 K-Means Clustering

6.1 Preliminaries

6.2 The K-Means Clustering Algorithm

6.3 Clustering Governors by Age and Longitude

6.4 K-Means Clustering Problems and Extensions

6.5 Real World Applications

6.6 Exercises

7 Fairly Simple Neural Networks

7.1 Biological Basis?

7.2 Artificial Neural Networks

7.2.1 Neurons

7.2.2 Layers

7.2.3 Backpropagation

7.2.4 The Big Picture

7.3 Preliminaries

7.3.1 Help with Randomization

7.3.2 Fast Arithmetic

7.3.3 The Activation Function

7.4 Building the Network

7.4.1 Neurons

7.4.2 Layers

7.4.3 The Network

7.5 Classification Problems

7.5.1 Normalizing Data

7.5.2 The Classic Iris Data Set

7.5.3 Classifying Wine

7.6 Neural Network Problems and Extensions

7.7 Real World Applications

7.8 Exercises

8 Miscellaneous Problems

8.1 The Knapsack Problem

8.2 The Travelling Salesman Problem

8.2.1 The Naive Approach

8.2.2 Taking it to the Next Level

8.3 Phone Number Mnemonics

8.4 Tic-Tac-Toe

8.4.1 Managing State

8.4.2 Minimax

8.5 Real World Applications

8.6 Exercises

Appendixes

Appendix A: A Glossary

Appendix B: B More Resources

B.1 Swift

B.2 iOS Development

B.3 Mac Development

B.4 Algorithms and Data Structures

B.5 Artificial Intelligence

B.6 Functional Programming

B.7 Open Source Projects Mentioned in this Book

Appendix C: C A Brief History of Swift

C.1 A Brief History of Programming Language Paradigms Incorporated in Swift

C.2 Programming Languages at Apple before Swift

C.3 Swift History

C.3.1 Milestones

C.3.2 Swift on Other Platforms

C.4 Swift Future Directions

About the Technology

Don't just learn another language. Become a better programmer instead. Today's awesome iOS apps stand on the shoulders of classic algorithms, coding techniques, and engineering principles. Master these core skills in Swift, and you'll be ready for AI, data-centric programming, machine learning, and the other development challenges that will define the next decade.

About the book

Classic Computer Science Problems in Swift deepens your Swift language skills by exploring foundational coding techniques and algorithms. As you work through examples in search, clustering, graphs, and more, you'll remember important things you've forgotten and discover classic solutions to your "new" problems. You'll appreciate author David Kopec's amazing ability to connect the core disciplines of computer science to the real-world concerns of apps, data, performance, and even nailing your next job interview!

What's inside

  • Breadth-first, depth-first, and A* search algorithms
  • Constraint-satisfaction problems
  • Solving problems with graph algorithms
  • Neural networks, genetic algorithms, and more
  • All examples written in Swift 4.1

About the reader

For readers comfortable with the basics of Swift.

About the author

David Kopec is an assistant professor of computer science and innovation at Champlain College in Burlington, Vermont. He is an experienced iOS developer and the author of Dart for Absolute Beginners.


placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks

An excellent book for all Swift programmers, and for students learning algorithms.

Julien Pohie, Dell

A hands-on and informative exploration of computer science problems.

Chad Johnston, Polaris Alpha

An extraordinary Swift language book and a contribution to the practice of Swift algorithmic problem solving.

Eric Giannini, Nexmo