Giter Site home page Giter Site logo

Comments (1)

barretlee avatar barretlee commented on May 27, 2024

动态联通图问题,需要将问题抽象成一个可编程的过程。书中提到触点、分量和连接,所以编程第一步,先初始化触点信息,简洁期间,每个触点信息保持跟他们的序号一样就行了。

  • union find,大致意思就是将所有联通的节点信息归并为一个,有点类似于物理电路中的电势,让各点电势一样;
  • quick union,将联通的两点按照顺序连接起来,有点像指针,a->b->c->d,保持串联,每次新的连接,都去判断两点的根指针是否一致,如果一致则略过,如果不一致则连接;
  • weighted quick union,在上面算法的基础上,添加了权重判断,每个节点除了序号信息外,还有一个数深度信息(size),当指针不一致需要连接时,将深度小的数合并到大的上面(我觉得这一步有点难理解)。

研究算法的实现还是挺有意思的,最难的地方莫过于对复杂度的计算和判断

from algorithms.

Related Issues (17)

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.