官术网_书友最值得收藏!

Sorting algorithms

The most common category of algorithm has to deal with sorting data, that is, placing it in a given order. The two most famous sorting algorithms are the following:

  • Quicksort: This is considered one of the fastest sorting algorithms. The average time that quicksort takes to sort its data is O (n log n), but this can grow up to O(n2) in the worst-case scenario, which mainly has to do with the way the data is presented for processing.
  • Bubble sort: This algorithm is pretty easy to implement with an O(n2) average complexity. If you want to start learning about sorting, start with bubble sort before looking into the more difficult to develop algorithms.
Although every algorithm has its disadvantages, if you do not have lots of data, the algorithm is not really important as long as it does the job.

What you should remember is, the way Go implements sorting internally cannot be controlled by the developer and it can change in the future; so, if you want to have full control over sorting, you should write your own implementation.

主站蜘蛛池模板: 连云港市| 如皋市| 镇坪县| 桐庐县| 花莲县| 丰原市| 济宁市| 泰顺县| 乳山市| 栖霞市| 高邑县| 岳普湖县| 乳源| 胶州市| 邯郸市| 广东省| 华亭县| 云梦县| 宝坻区| 杭州市| 廉江市| 普兰店市| 湘阴县| 民丰县| 玉林市| 新昌县| 长宁县| 综艺| 天全县| 佳木斯市| 枝江市| 辰溪县| 双峰县| 香格里拉县| 石城县| 忻州市| 嘉峪关市| 金湖县| 施甸县| 徐汇区| 青铜峡市|