Kodeco Forums

Swift Algorithm Club: April 2017 Digest

Check out the latest news from the Swift Algorithm Club in April, including news from the RWDevCon workshop, and a brand new Swift algorithm!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/644-swift-algorithm-club-april-2017-digest

Hi Please tell us that in which situation or circumstances can use conventional data structure in ios development , like when can we use link list, trees

One of my favourite examples is an app that contains a search screen. Let’s take a To-Do app as an example. If you want to power prefix matching for your search through your saved entries, a Trie tree is a great data structure to use.

A game employing the mechanics of the Josephus problem might use Linked Lists as a model for the deletion algorithm.

IMO, the biggest benefit of data structures is that each data structure tackles a very well defined problem. This reinforces the idea of encapsulation in OOP and reduces the chance for bugs in situations where you need them.

For example, if you wanted to create a queuing mechanism for your app, you could just use a plain array and interact with it as a queue. It’ll be inherently dangerous to do so though, since the array is exposed for modifications. Creating a Queue type that only exposes the queue related methods will guard against unwanted modifications.