English 中文(简体)
插入Sort 和 FingerTreeSort 的无症状运行时间
原标题:Asymptotic runtimes of InsertionSort and FingerTreeSort

我查过书本的高度和低度 和互联网上的几个网站一样 但我只是不太清楚我的答案

I need to give asymptotic runtimes of InsertionSort and FingerTreeSort (based on RB-Trees), in regards to the number of inversions present. InsertionSort runs in O(n+INV) time and FingerTreeSort runs in O(n+n*lg(INV/n+1). I need to give asymptotic runtimes for INV = 0, n, n^1.5 and n^2/4.

我所想到的是,插入Sort 运行在:O(n),O(n),O(n),O(n),O(n)2和O(n)2

这是否正确?为什么不呢?(我特别不确定INV=n和n1.5)

对于FingerTreeSort: O(n*lg(n)、O(n*lg(n)、O(n)lg(sqrt(n))和O(n*lg(n)))

I m in doubt about all of the ones in FingerTreeSort, but these are how I think they should be. How do I find the right asymptotic runtime? For instance for FingerTreeSort and n^1.5, I m thinking that it would give O(n+n*lg(n^1.5/n+1) by plugging into the general runtime, and simplifying: O(n+n*lg(sqrt(n)+1) and seeing as it s asymptotic, I can disregard the lower figures such as +1 and +n giving me O(n*lg(sqrt(n))). Is this the correct way of doing it?

事先感谢回答这个问题的人。

p. 以java书写,与问题无关。

问题回答

Insertion Sort :
Formula : O(n + inv)
inv = 0 : O(n)
inv = O(n) : O(n +n) = O(n)
inv = O(n^1.5) : O(n+n^1.5) = O(n^1.5)
inv = (n^2)/4 : O(n + n^2) = O(n^2)

FingerTreeSort :
Formula (using the one supplied by OP) : O( n + n*(ln[(inv/n) +1 ] ) )
inv = 0 : O(n)
inv = O(n) : O(n + n*( ln[( O(n)/n ) + 1] ) ) = O(n + n*( ln[ O(1) +1] )) = O(n)
inv = O(n^1.5) : O(n + n*( ln[( O(n^1.5)/n ) + 1] ) ) = O(n + n*( ln[ c*(n^0.5) + 1] ) ) =
O(n + 0.5*n*ln(n)) = O(n*ln (n))
Similarly,for inv = O(n^2) : O(n*ln(n))





相关问题
Silverlight 3 Dataform - how to add fieds at runtime

I am creating a DataForm from dynamic data (so I can t create the columns in the xaml), I currently create columns for my DataGrid (I have not worked out how I can create a button + event in a colomn ...

starting vlc player in java

I tried to start vlc player in Java, but somehow it did not word. Any other Prog I tried worked. Plz have a look at my code: try { Runtime.getRuntime().exec("K:\...\vlc.exe"); } catch (...

How to generate an instance of an unknown type at runtime?

i ve got the following in C#: string typename = "System.Int32"; string value = "4"; theses two strings should be taken to generate an object of the specified type with the specified value... result ...

Obtaining a proc pointer to a Carbon API at runtime

I have a Mac application that I must build against the Mac OS 10.4 SDK for various reasons beyond my control. Given that my application s minimum OS version will be 10.5. (I know, I know... but I can ...

热门标签