This repository was archived by the owner on Aug 12, 2018. It is now read-only.

iCell/swift-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

This repository contains Swift based examples of many popular algorithms and data structures, and this repository is inspired by JavaScript-Algorithms

This repository is still working in progress.

Each algorithm and data structure have its own separate README with related explanations and links for further reading and YouTube videos.

Data structure is a particular way of organizing and storing data in a computer so that it can be accessed and modified efficiently. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.

  • Linked List
  • Queue
  • Stack
  • Hash Table
  • Heap
  • Priority Queue
  • Trie
  • Tree
  • Binary Search Tree
  • AVL Tree
  • Red-Black Tree
  • Suffix Tree
  • Segment Tree or Interval Tree
  • Binary Indexed Tree or Fenwick Tree
  • Graph
  • Disjoint Set

▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)

Order of growth of algorithms specified in Big O notation.

Big O graphs

Source: Big O Cheat Sheet.

Below is the list of some of the most used Big O notations and their performance comparisons against different sizes of the input data.

Big O NotationComputations for 10 elementsComputations for 100 elementsComputations for 1000 elements
O(1)111
O(log N)369
O(N)101001000
O(N log N)306009000
O(N^2)100100001000000
O(2^N)10241.26e+291.07e+301
O(N!)36288009.3e+1574.02e+2567
Data StructureAccessSearchInsertionDeletionComments
Array1nnn
Stacknn11
Queuenn11
Linked Listnn11
Hash Table-nnnIn case of perfect hash function costs would be O(1)
Binary Search TreennnnIn case of balanced tree costs would be O(log(n))
B-Treelog(n)log(n)log(n)log(n)
Red-Black Treelog(n)log(n)log(n)log(n)
AVL Treelog(n)log(n)log(n)log(n)
NameBestAverageWorstMemoryStableComments
Bubble sortnn^2n^21Yes
Insertion sortnn^2n^21Yes
Selection sortn^2n^2n^21No
Heap sortn log(n)n log(n)n log(n)1No
Merge sortn log(n)n log(n)n log(n)nYes
Quick sortn log(n)n log(n)n^2log(n)No
Shell sortn log(n)depends on gap sequencen (log(n))^21No
Counting sortn + rn + rn + rn + rYesr - biggest number in array
Radix sortn * kn * kn * kn + kYesk - length of longest key

About

Algorithms and data structures implemented in Swift with explanations and links to further readings

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages