Questions tagged «construction»

17
如何建立堆的时间复杂度为O(n)?
有人可以帮助解释如何建立堆的O(n)复杂性吗? 将项目插入堆中是O(log n),插入重复n / 2次(其余为叶子,并且不能违反堆属性)。因此,O(n log n)我认为这意味着复杂度应为。 换句话说,对于我们“堆砌”的每个项目,它有可能不得不针对到目前为止的堆的每个级别(即log n个级别)过滤一次。 我想念什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.