简体   繁体   中英

What would constitute an O(n^2 log n) algorithm?

I am a beginner and am learning about O notation and runtime.

I am unsure of what an O(n^2 log n) algorithm would look like. For example, I believe that the merge sort algorithm is O(n log n), but if I were to use this to, for example, merge sort a 2d array: first looping through the rows and columns using a nested loop and appending those to a new list to make a single list and then using a merge sort algorithm on this list, would that be O(n^2 log n)?

Thanks,

Being unable to find an example I will just construct an example.

log N usually implies a binary search. And there are plenty of N^2 algorithms.

Say you implement a bubble sort O(N^2), unfortunately you have to make a lookup of the sort values for each operation by using a binary search.

This is of course stupid, as you should memorize the values and not use bubble sort at all.

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