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

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.

主站蜘蛛池模板: 梨树县| 邹城市| 子长县| 延吉市| 孝感市| 休宁县| 大渡口区| 南江县| 阳原县| 清远市| 商南县| 庄河市| 莱西市| 遂宁市| 玉屏| 水富县| 图片| 肥城市| 烟台市| 嵩明县| 泸溪县| 威远县| 富川| 海门市| 来凤县| 泊头市| 临漳县| 绵阳市| 易门县| 科技| 伊宁市| 沧州市| 台前县| 施秉县| 娱乐| 郸城县| 靖州| 镇坪县| 阳谷县| 乐清市| 教育|