Learning Big O Notation with Swift

However, linear-based activities still provide value when prototyping complex systems in a technical interview or real-world setting.CONSTANT TIMEWhen evaluating algorithms, it’s often ideal to code a solution where the size of the data input has no direct relationship on performance..Consider successful search algorithms like Google or machine learning solutions used on websites like Netflix and Amazon..These systems run in constant time and are represented with the symbol O(1)..A significant difference between a linear and constant operation is logic..In the case of Google, many hardware and software complexities are put in place to ensure things work as quickly as possible..However, not all constant time operations need to be complicated..Consider the following://constant time operations – O(1)class Stack<T> { var store : [T] = []func peek() -> T?.{ return store.last }func push(_ value: T) { store.append(value) }func pop() -> T?.{ return store.isEmpty?.nil : store.removeLast() }}Known as a Stack data structure, this implementation is a favorite among hiring managers when conducting technical interviews..The reason?.A Stack combines ideas found in native iOS Development (e.g., UINavigationController) along with specific language syntax (e.g., collections and generics) coupled with knowledge of Big O Notation.. More details

Leave a Reply