Swift 3.1 Algorithms
http://www.knowstack.com/swift-3-1-algorithms-part-1/ In this post we will implement the following algorithms in Swift Implementing a stack in Swift Implementing a queue in Swift Prime Numbers – Check if a number is prime List of Prime numbers less than a given number Binary Search Binary Search Using Swift Generics Quick Sort Selection Sort Insertion Sort Recursively Searching a File in folders and sub folders Bubblesort Merge Sort Implementing a Stack in Swift In this sample we will implement a stack using an array. The stack has a first in last out or last in first out implementation. We can push an element to the top of the stack and pop to remove the top element of the stack. The pop function will remove and return the top most element of the stack. We can also have a function called as lastObject that returns the top most element of the stack without removing it from the stack. import Cocoa struct Stack { fileprivate var array = [ T ]()...