You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The choice of data structure for a particular task depends on a few things.
21
+
22
+
First, there is the shape of your data and the kinds of operations that you'll need to perform on it. If you want to look up objects by a key you need some kind of dictionary; if your data is hierarchical in nature you want a tree structure of some sort; if your data is sequential you want a stack or queue.
23
+
24
+
Second, it matters what particular operations you'll be performing most, as certain data structures are optimized for certain actions. For example, if you often need to find the most important object in a collection, then a heap or priority queue is more optimal than a plain array.
25
+
26
+
Most of the time using just the built-in Array, Dictionary, and Set types is sufficient, but sometimes you may want something more fancy...
27
+
28
+
### Trees
29
+
- Heap. A binary tree stored in an array, so it doesn't use pointers. Makes a great priority queue.
30
+
Fibonacci Heap
31
+
- B-Tree. A self-balancing search tree, in which nodes can have more than two children.
32
+
33
+
### Hashing
34
+
- Hash Table. Allows you to store and retrieve objects by a key. This is how the dictionary type is usually implemented.
35
+
36
+
### Graphs
37
+
- Graph.
38
+
39
+
## Learn more!
40
+
41
+
For more information, check out these great books:
42
+
43
+
-[Introduction to Algorithms](https://mitpress.mit.edu/books/introduction-algorithms) by Cormen, Leiserson, Rivest, Stein
44
+
-[The Algorithm Design Manual](http://www.algorist.com) by Skiena
45
+
-[Elements of Programming Interviews](http://elementsofprogramminginterviews.com) by Aziz, Lee, Prakash
46
+
-[Algorithms](http://www.cs.princeton.edu/~rs/) by Sedgewick
47
+
-[Grokking Algorithms](https://www.manning.com/books/grokking-algorithms) by Aditya Bhargava
48
+
49
+
The following books are available for free online:
50
+
51
+
-[Algorithms](http://www.beust.com/algorithms.pdf) by Dasgupta, Papadimitriou, Vazirani
52
+
-[Algorithms, Etc.](http://jeffe.cs.illinois.edu/teaching/algorithms/) by Erickson
53
+
-[Algorithms + Data Structures = Programs](http://www.ethoberon.ethz.ch/WirthPubl/AD.pdf) by Wirth
54
+
- Algorithms and Data Structures: The Basic Toolbox by Mehlhorn and Sanders
55
+
-[Open Data Structures](http://opendatastructures.org) by Pat Morin
56
+
-[Wikibooks: Algorithms and Implementations](https://en.wikibooks.org/wiki/Algorithm_Implementation)
57
+
58
+
Other algorithm repositories:
59
+
60
+
-[EKAlgorithms](https://github.com/EvgenyKarkan/EKAlgorithms). A great collection of algorithms in Objective-C.
61
+
-[@lorentey](https://github.com/lorentey/). Production-quality Swift implementations of common algorithms and data structures.
62
+
-[Rosetta Code](http://rosettacode.org). Implementations in pretty much any language you can think of.
63
+
-[AlgorithmVisualizer](http://jasonpark.me/AlgorithmVisualizer/). Visualize algorithms on your browser.
64
+
-[Swift Structures](https://github.com/waynewbishop/SwiftStructures) Data Structures with directions on how to use them [here](http://waynewbishop.com/swift)
0 commit comments