为什么归并排序最坏情况下的运行时间为O(n log n)的?

编程入门 行业动态 更新时间:2024-10-20 03:40:53
本文介绍了为什么归并排序最坏情况下的运行时间为O(n log n)的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人能向我解释,在简单的英语或一个简单的方法来解释它?

Can someone explain to me in simple English or an easy way to explain it?

推荐答案

在传统的归并排序,每次通过数据加倍排序小节的大小。第一遍之后,该文件将被分类到长度的两个部分。第二遍后,长度为4。然后8,16,等等直至文件的大小。

On a "traditional" merge sort, each pass through the data doubles the size of the sorted subsections. After the first pass, the file will be sorted into sections of length two. After the second pass, length four. Then eight, sixteen, etc. up to the size of the file.

这是需要保持排序节的规模扩大一倍,直到有一个部分包括整个文件。这将需要lg的截面尺寸(N)的倍增到达文件的大小,以及数据的每遍需要时间成比例的记录数

It's necessary to keep doubling the size of the sorted sections until there's one section comprising the whole file. It will take lg(N) doublings of the section size to reach the file size, and each pass of the data will take time proportional to the number of records.

更多推荐

为什么归并排序最坏情况下的运行时间为O(n log n)的?

本文发布于:2023-11-30 19:57:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651313.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间为   最坏   情况下   log

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!