合并运行时间字典分类排序最坏的情况?

编程入门 行业动态 更新时间:2024-10-11 13:27:10
本文介绍了合并运行时间字典分类排序最坏的情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每个长度为n的n个字符串列表分类到使用合并排序算法字典顺序。这个计算的最坏情况下的运行时间是?

A list of n strings each of length n is sorted into lexicographic order using the merge sort algorithm. The worst case running time of this computation is?

我得到这个问题的一门功课。我知道在O(nlogn)时间合并排序排序。对于字典顺序长度是n次nlogn?或N ^ 2?

I got this question as a homework. I know merge sort sorts in O(nlogn) time. For lexicographic order for length in is it n times nlogn ? or n^2 ?

推荐答案

算法的每比较 O(N) [比较两个字符串的 O(N)最坏的情况 - 你可能会发现这是只在最后一个字符大],你有 O(nlogn)比较在合并排序。

Each comparison of the algorithm is O(n) [comparing two strings is O(n) worst case - you might detect which is "bigger" only on the last character], You have O(nlogn) comparisons in mergesort.

这样你可以获得 O(nlogn * N)=为O(n ^ 2 * LOGN)

更多推荐

合并运行时间字典分类排序最坏的情况?

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

发布评论

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

>www.elefans.com

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