|
120 | 120 | * Sorting Algorithms [Wikipedia](https://en.wikipedia.org/wiki/Sorting_algorithm?oldformat=true)
|
121 | 121 | - Using the most efficient sorting algorithm (and correct data structures that implement it) is vital for any program, because data manipulation can be one of the most significant bottlenecks in case of performance and the main purpose of spending time, determining the best algorithm for the job, is to drastically improve said performance. The efficiency of an algorithm is measured in its' "Big O" ([StackOverflow](https://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation)) score. Really good algorithms perform important actions in O(n log n) or even O(log n) time and some of them can even perform certain actions in O(1) time (HashTable insertion, for example). But there is always a trade-off - if some algorithm is really good at adding a new element to a data structure, it is, most certainly, much worse at data access than some other algorithm. If you are proficient with math, you may notice that "Big O" notation has many similarities with "limits", and you would be right - it measures best, worst and average performances of an algorithm in question, by looking at its' function limit. It should be noted that, when we are speaking about O(1) - constant time - we are not saying that this algorithm performs an action in one operation, rather that it can perform this action with the same number of operations (roughly), regrardless of the amount of elements it has to take into account. Thankfully, a lot of "Big O" scores have been already calculated, so you don't have to guess, which algorithm or data structure will perform better in your project. ["Big O" cheat sheet](http://bigocheatsheet.com/)
|
122 | 122 | * Bubble sort
|
| 123 | + <table> |
| 124 | + <tr> |
| 125 | + <th colspan="3" align="center">Time Complexity</th> |
| 126 | + <th align="center">Space Complexity</th> |
| 127 | + </tr> |
| 128 | + <tr> |
| 129 | + <th align="center">Best</th> |
| 130 | + <th align="center">Avegage</th> |
| 131 | + <th align="center">Worst</th> |
| 132 | + <th align="center">Worst</th> |
| 133 | + </tr> |
| 134 | + <tr> |
| 135 | + <td align="center">Ω(n)</td> |
| 136 | + <td align="center">Θ(n^2)</td> |
| 137 | + <td align="center">O(n^2)</td> |
| 138 | + <td align="center">O(1)</td> |
| 139 | + </td> |
| 140 | + </tr> |
| 141 | + </table> |
123 | 142 | * Selection sort
|
| 143 | + <table> |
| 144 | + <tr> |
| 145 | + <th colspan="3" align="center">Time Complexity</th> |
| 146 | + <th align="center">Space Complexity</th> |
| 147 | + </tr> |
| 148 | + <tr> |
| 149 | + <th align="center">Best</th> |
| 150 | + <th align="center">Avegage</th> |
| 151 | + <th align="center">Worst</th> |
| 152 | + <th align="center">Worst</th> |
| 153 | + </tr> |
| 154 | + <tr> |
| 155 | + <td align="center">Ω(n^2)</td> |
| 156 | + <td align="center">Θ(n^2)</td> |
| 157 | + <td align="center">O(n^2)</td> |
| 158 | + <td align="center">O(1)</td> |
| 159 | + </td> |
| 160 | + </tr> |
| 161 | + </table> |
124 | 162 | * Insertion sort
|
| 163 | + <table> |
| 164 | + <tr> |
| 165 | + <th colspan="3" align="center">Time Complexity</th> |
| 166 | + <th align="center">Space Complexity</th> |
| 167 | + </tr> |
| 168 | + <tr> |
| 169 | + <th align="center">Best</th> |
| 170 | + <th align="center">Avegage</th> |
| 171 | + <th align="center">Worst</th> |
| 172 | + <th align="center">Worst</th> |
| 173 | + </tr> |
| 174 | + <tr> |
| 175 | + <td align="center">Ω(n)</td> |
| 176 | + <td align="center">Θ(n^2)</td> |
| 177 | + <td align="center">O(n^2)</td> |
| 178 | + <td align="center">O(1)</td> |
| 179 | + </td> |
| 180 | + </tr> |
| 181 | + </table> |
125 | 182 | * Merge sort
|
| 183 | + <table> |
| 184 | + <tr> |
| 185 | + <th colspan="3" align="center">Time Complexity</th> |
| 186 | + <th align="center">Space Complexity</th> |
| 187 | + </tr> |
| 188 | + <tr> |
| 189 | + <th align="center">Best</th> |
| 190 | + <th align="center">Avegage</th> |
| 191 | + <th align="center">Worst</th> |
| 192 | + <th align="center">Worst</th> |
| 193 | + </tr> |
| 194 | + <tr> |
| 195 | + <td align="center">Ω(n log(n))</td> |
| 196 | + <td align="center">Θ(n log(n))</td> |
| 197 | + <td align="center">O(n log(n))</td> |
| 198 | + <td align="center">O(n)</td> |
| 199 | + </td> |
| 200 | + </tr> |
| 201 | + </table> |
126 | 202 | * Quick sort
|
| 203 | + <table> |
| 204 | + <tr> |
| 205 | + <th colspan="3" align="center">Time Complexity</th> |
| 206 | + <th align="center">Space Complexity</th> |
| 207 | + </tr> |
| 208 | + <tr> |
| 209 | + <th align="center">Best</th> |
| 210 | + <th align="center">Avegage</th> |
| 211 | + <th align="center">Worst</th> |
| 212 | + <th align="center">Worst</th> |
| 213 | + </tr> |
| 214 | + <tr> |
| 215 | + <td align="center">Ω(n^2)</td> |
| 216 | + <td align="center">Θ(n^2)</td> |
| 217 | + <td align="center">O(n^2)</td> |
| 218 | + <td align="center">O(1)</td> |
| 219 | + </td> |
| 220 | + </tr> |
| 221 | + </table> |
127 | 222 | * Hash Table or Hash Map
|
128 | 223 | * Breadth First Search
|
129 | 224 | * Depth First Search
|
|
0 commit comments