Coder Social home page Coder Social logo

Comments (1)

AndrewOYLK avatar AndrewOYLK commented on June 19, 2024

总结的挺详细,我也稍微补充下:

  1. 数组
    在随机访问的情况下,即通过索引访问数组中的元素时,时间复杂度是O(1)
    但是如果需要查找指定的值时,是需要遍历数据,这时时间复杂度是O(n)

  2. 链表
    不支持随机访问,所以查看指定值时需要遍历链表,所以时间复杂度时O(n)
    在插入、删除操作的时候,需要考虑是否需要先查找数据,如果先查找数据,再执行插入和删除那么时间复杂度也是O(n),如果是在已知结点的情况下进行插入或者删除,这时候时间复杂度是O(1)

小结:主要想表述的是,要区分是否是给定值还是需要查找指定值的情况下,去判断数组和链表在查找、插入、删除的时间复杂度

from algorithm007-class02.

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.