Quantcast
Channel: Kodeco | High quality programming tutorials: iOS, Android, Swift, Kotlin, Unity, and more
Viewing all articles
Browse latest Browse all 4370

Swift Algorithm Club: June Digest 2017

$
0
0

SwiftAlgClub-Sept-Digest-feature

The Swift Algorithm Club is a popular open source project to implement popular algorithms and data structures in Swift, with over 13,000 stars on GitHub.

We periodically give status updates with how things are going with the project. There’s been quite a few updates to the repo this month, including 3 brand new contributions:

Let’s dig in!

Minimum Coin Change

In the traditional coin change problem, you have to find all the different ways to change some money given a set of coins (i.e. 1 cent, 2 cents, 5 cents, 10 cents etc.).

For example, if you have the value of 4 Euro cents, that can be changed in three possible ways:

  • Four 1 cent coins
  • Two 2 cent coins
  • One 2 cent coin and two 1 cent coins

The minimum coin change problem is a variation of the generic coin change problem, where you need to find the option that returns the least number of coins.

You can learn how to implement this in Swift here:

Dijkstra’s Algorithm

This algorithm was invented in 1956 by Edsger W. Dijkstra, and is one of the most effective algorithms in finding the shortest paths from one point to all other points in a graph.

The best example is a road network. If you want to find the shortest path from two points, let’s say, from your house to your workplace, then you would use Dijkstra’s algorithm.

You can learn how to implement this in Swift here:

Minimum Spanning Tree

A minimum spanning tree (MST) of a connected undirected weighted graph has a subset of the edges from the original graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. There can be more than one MSTs of a graph.

There are two popular algorithms to calculate MST of a graph – Kruskal’s algorithm and Prim’s algorithm. Both algorithms have a total time complexity of O(ElogE) where E is the number of edges from the original graph.

You can learn how to implement this in Swift here:

Where To Go From Here?

The Swift Algorithm Club is always looking for new members. Whether you’re here to learn or here to contribute, we’re happy to have you around.

To learn more about the Swift Algorithm Club, check out our introductory article. We hope to see you at the club! :]

The post Swift Algorithm Club: June Digest 2017 appeared first on Ray Wenderlich.


Viewing all articles
Browse latest Browse all 4370

Trending Articles