swift-algorithm-club README

The project's README from github.com/kodecocodes/swift-algorithm-club. As one markdown file: README.md.

Swift Algorithm Club

Welcome to the Swift Algorithm Club!

Here you'll find implementations of popular algorithms and data structures in everyone's favorite new language Swift, with detailed explanations of how they work.

If you're a computer science student who needs to learn this stuff for exams -- or if you're a self-taught programmer who wants to brush up on the theory behind your craft -- you've come to the right place!

The goal of this project is to explain how algorithms work. The focus is on clarity and readability of the code, not on making a reusable library that you can drop into your own projects. That said, most of the code should be ready for production use but you may need to tweak it to fit into your own codebase.

Code is compatible with Xcode 10 and Swift 4.2. We'll keep this updated with the latest version of Swift. If you're interested in a GitHub pages version of the repo, check out this.

:heart_eyes: Suggestions and contributions are welcome! :heart_eyes:

What are algorithms and data structures? Pancakes!

Why learn algorithms? Worried this isn't your cup of tea? Then read this.

Big-O notation. We often say things like, "This algorithm is O(n)." If you don't know what that means, read this first.

Algorithm design techniques. How do you create your own algorithms?

How to contribute. Report an issue to leave feedback, or submit a pull request.

Where to start?

If you're new to algorithms and data structures, here are a few good ones to start out with:

The algorithms

Searching

Sorting

It's fun to see how sorting algorithms work, but in practice you'll almost never have to provide your own sorting routines. Swift's own sort() is more than up to the job. But if you're curious, read on...

Basic sorts:

Fast sorts:

Hybrid sorts:

Special-purpose sorts:

Bad sorting algorithms (don't use these!):

Compression

Miscellaneous

Mathematics

Machine learning

Data structures

The choice of data structure for a particular task depends on a few things.

First, there is the shape of your data and the kinds of operations that you'll need to perform on it. If you want to look up objects by a key you need some kind of dictionary; if your data is hierarchical in nature you want a tree structure of some sort; if your data is sequential you want a stack or queue.

Second, it matters what particular operations you'll be performing most, as certain data structures are optimized for certain actions. For example, if you often need to find the most important object in a collection, then a heap or priority queue is more optimal than a plain array.

Most of the time using just the built-in Array, Dictionary, and Set types is sufficient, but sometimes you may want something more fancy...

Variations on arrays

Queues

Lists

Trees

Hashing

Sets

Graphs

Puzzles

A lot of software developer interview questions consist of algorithmic puzzles. Here is a small selection of fun ones. For more puzzles (with answers), see here and here.

Learn more!

Like what you see? Check out Data Structures & Algorithms in Swift, the official book by the Swift Algorithm Club team!

Data Structures & Algorithms in Swift Book

You’ll start with the fundamental structures of linked lists, queues and stacks, and see how to implement them in a highly Swift-like way. Move on to working with various types of trees, including general purpose trees, binary trees, AVL trees, binary search trees, and tries.

Go beyond bubble and insertion sort with better-performing algorithms, including mergesort, radix sort, heap sort, and quicksort. Learn how to construct directed, non-directed and weighted graphs to represent many real-world models, and traverse graphs and trees efficiently with breadth-first, depth-first, Dijkstra’s and Prim’s algorithms to solve problems such as finding the shortest path or lowest cost in a network.

By the end of this book, you’ll have hands-on experience solving common issues with data structures and algorithms — and you’ll be well on your way to developing your own efficient and useful implementations!

You can find the book on the raywenderlich.com store.

Credits

The Swift Algorithm Club was originally created by Matthijs Hollemans.

It is now maintained by Vincent Ngo, Kelvin Lau, and Richard Ash.

The Swift Algorithm Club is a collaborative effort from the most algorithmic members of the raywenderlich.com community. We're always looking for help - why not join the club? :]

License

All content is licensed under the terms of the MIT open source license.

By posting here, or by submitting any pull request through this forum, you agree that all content you submit or create, both code and text, is subject to this license. Razeware, LLC, and others will have all the rights described in the license regarding this content. The precise terms of this license may be found here.

Build Status

swift-algorithm-club (kodecocodes/swift-algorithm-club)

Searching Database…

Что это такое?Swift Algorithm Club — это собранная сообществом коллекция реализаций популярных алгоритмов и структур данных на Swift, и к каждой из них прилагается подробное объяснение того, как она работает.
Это библиотека, которую я могу встроить в своё приложение, или скорее учебный справочник?В первую очередь это учебный справочник: проект намеренно ставит на первое место понятный и читаемый код, а не создание библиотеки для повторного использования. Хотя большинство фрагментов можно применять и в продакшене, немного доработав их.
Как устроен список и с чего новичку лучше начать?Записи сгруппированы по темам: поиск, поиск по строкам, сортировка, сжатие, математика, машинное обучение и структуры данных (массивы, очереди, списки, деревья, хеширование, множества, графы), а также раздел «Головоломки» с задачами в духе собеседований. Новичкам рекомендуется начать со стека, очереди, сортировки вставками, бинарного поиска и бинарного дерева поиска, сортировки слиянием и поиска по строкам Бойера–Мура.
Для какой версии Xcode и Swift написан код?Код написан для Xcode 10 и Swift 4.2, а авторы говорят, что планируют поддерживать его в актуальном состоянии с выходом новых версий Swift.
Годится ли код отсюда для продакшена в том виде, в котором он есть?В основном да, но без гарантий «из коробки»: авторы говорят, что фрагмент, возможно, придётся подогнать под вашу кодовую базу, ведь главным приоритетом при разработке была ясность, а не возможность повторного использования.
Что такое сопутствующая книга «Data Structures & Algorithms in Swift»?Это официальная платная книга от команды Swift Algorithm Club. В ней разбираются те же связные списки, деревья, сортировки и графовые алгоритмы с практическими реализациями на Swift. Книга продаётся в магазине raywenderlich.com.
А есть ли здесь алгоритмы машинного обучения?Да, в отдельном разделе машинного обучения есть кластеризация методом k-средних, алгоритм k-ближайших соседей, линейная и логистическая регрессия, нейронные сети, PageRank, наивный байесовский классификатор и имитация отжига.
Есть ли задачи для тренировки в духе собеседований?Да, в разделе «Головоломки» собраны классические вопросы с собеседований: Two-Sum, FizzBuzz, задача Монти Холла, задача о яйцах (Egg Drop) и задача об обедающих философах.
Size
13.8 MB
Stars
29.1K
Updated
CommitDec 06
Age
10y
Commits · 90 Days