简体   繁体   中英

Insertion sort algorithm with sorted list

我正在准备算​​法考试,并且有以下问题:如果我们为insertion sort algorithm提供一个排序列表,它是否仍需要O(n ^ 2)?

No it should run in O(n) time as this is the best case for this algorithm

https://en.wikipedia.org/wiki/Insertion_sort

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM