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

  • Go Systems Programming
  • Mihalis Tsoukalos
  • 183字
  • 2021-07-02 18:08:05

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.

主站蜘蛛池模板: 若羌县| 三都| 民县| 麦盖提县| 辽中县| 安达市| 东辽县| 崇明县| 闸北区| 山阴县| 林西县| 昌平区| 南岸区| 弋阳县| 昌图县| 乌鲁木齐市| 黑龙江省| 龙门县| 西贡区| 中山市| 青浦区| 会东县| 金坛市| 紫阳县| 宜兴市| 湛江市| 孟村| 新邵县| 谢通门县| 双峰县| 扎囊县| 通渭县| 西盟| 阜康市| 车致| 虎林市| 池州市| 阿尔山市| 霍山县| 交城县| 大庆市|