Giter Site home page Giter Site logo

归并排序 about goa.c HOT 4 OPEN

hunterhug avatar hunterhug commented on May 20, 2024
归并排序

from goa.c.

Comments (4)

baici1 avatar baici1 commented on May 20, 2024

你在自底而上归并排序里面对于空间复杂度的分析有问题!
从你的描述中感觉空间复杂度只和函数递归栈有关,但是你的算法中用到一个N长度的辅助数组,其实我觉得空间复杂度为O(N)。
这是我的看法。

from goa.c.

baici1 avatar baici1 commented on May 20, 2024

那个手摇算法在leetcode上面使用,我觉得可以填上去。
题目:剑指Offer58-II.左旋转字符串
leetcode 还是有用的!哈哈哈哈哈哈

from goa.c.

hunterhug avatar hunterhug commented on May 20, 2024

@baici1
你在自底而上归并排序里面对于空间复杂度的分析有问题!
从你的描述中感觉空间复杂度只和函数递归栈有关,但是你的算法中用到一个N长度的辅助数组,其实我觉得空间复杂度为O(N)。
这是我的看法。

文章下面的手摇算法就节省了辅助数组的空间。如果没有原地排序,你确实可以说空间复杂度是O(N),但是根据上下文,我们讨论的是两种方法的区别,空间上的复杂度只要考虑的是递归,自顶向下空间复杂度更大。

from goa.c.

hunterhug avatar hunterhug commented on May 20, 2024

@baici1
那个手摇算法在leetcode上面使用,我觉得可以填上去。
题目:剑指Offer58-II.左旋转字符串
leetcode 还是有用的!哈哈哈哈哈哈

实际上,不是leetcode有用,你要明白这一点。

from goa.c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.