当前位置: 首页 > news >正文

建设 大型电子商务网站怎么创建自己的网站平台

建设 大型电子商务网站,怎么创建自己的网站平台,制作网制作网站建设的公司,人大网站建设情况目录 1 基础知识2 模板3 工程化 1 基础知识 并查集支持O(1)时间复杂度实现: 将两个集合合并。询问两个元素是否在一个集合中。 基本原理:每个集合用一颗树来表示。树根的编号就是整个集合的编号。每个结点存储它的父结点,p[x]表示x的父结点…

目录

  • 1 基础知识
  • 2 模板
  • 3 工程化

1 基础知识

并查集支持O(1)时间复杂度实现:

  1. 将两个集合合并。
  2. 询问两个元素是否在一个集合中。

基本原理:每个集合用一颗树来表示。树根的编号就是整个集合的编号。每个结点存储它的父结点,p[x]表示x的父结点。

问题1:如何判断树根:p[x] == x
问题2:如何求x的集合编号:while (p[x] != x) x = p[x];。上述为朴素做法,可以通过路径压缩,进行优化。

int find(int x) {if (p[x] != x) p[x] = find(p[x]);return p[x];
}

问题3:如何合并两个集合:px是x的集合编号,py是y的集合编号:p[px] = py

2 模板

(1)朴素并查集:int p[N]; //存储每个点的祖宗节点// 返回x的祖宗节点int find(int x){if (p[x] != x) p[x] = find(p[x]);return p[x];}// 初始化,假定节点编号是1~nfor (int i = 1; i <= n; i ++ ) p[i] = i;// 合并a和b所在的两个集合:p[find(a)] = find(b);(2)维护size的并查集:int p[N], size[N];//p[]存储每个点的祖宗节点, size[]只有祖宗节点的有意义,表示祖宗节点所在集合中的点的数量// 返回x的祖宗节点int find(int x){if (p[x] != x) p[x] = find(p[x]);return p[x];}// 初始化,假定节点编号是1~nfor (int i = 1; i <= n; i ++ ){p[i] = i;size[i] = 1;}// 合并a和b所在的两个集合:size[find(b)] += size[find(a)];p[find(a)] = find(b);(3)维护到祖宗节点距离的并查集:int p[N], d[N];//p[]存储每个点的祖宗节点, d[x]存储x到p[x]的距离// 返回x的祖宗节点int find(int x){if (p[x] != x){int u = find(p[x]);d[x] += d[p[x]];p[x] = u;}return p[x];}// 初始化,假定节点编号是1~nfor (int i = 1; i <= n; i ++ ){p[i] = i;d[i] = 0;}// 合并a和b所在的两个集合:p[find(a)] = find(b);d[find(a)] = distance; // 根据具体问题,初始化find(a)的偏移量

3 工程化

class UnionFind {
public:UnionFind(int n) {this->n = n;p.resize(n);cnt.resize(n);d.resize(n);for (int i = 0; i < n; ++i) {p[i] = i;cnt[i] = 1;d[i] = 0;}}int find(int x) {if (x != p[x]) {int u = find(p[x]);d[x] += d[p[x]];p[x] = u;}return p[x];}void merge(int x, int y) {int px = find(x), py = find(y);if (px != py) {p[px] = py;cnt[py] += cnt[px];		}return;}int size(int x) {//返回x所在集合的大小return cnt[find(x)];}
private:int n;vector<int> p; //存储父结点vector<int> cnt; //存储集合大小,根结点的cnt才有意义vector<int> d; //存储到根结点的距离
};

文章转载自:
http://megalopteran.c7500.cn
http://phlebosclerosis.c7500.cn
http://paranormal.c7500.cn
http://pretor.c7500.cn
http://condonable.c7500.cn
http://suckle.c7500.cn
http://thermotolerant.c7500.cn
http://undesired.c7500.cn
http://hackery.c7500.cn
http://ent.c7500.cn
http://scottie.c7500.cn
http://bumf.c7500.cn
http://tun.c7500.cn
http://eyedrop.c7500.cn
http://elodea.c7500.cn
http://floristry.c7500.cn
http://aluminise.c7500.cn
http://sophi.c7500.cn
http://inveteracy.c7500.cn
http://constitutional.c7500.cn
http://hedwig.c7500.cn
http://tantrum.c7500.cn
http://triphenylcarbinol.c7500.cn
http://milia.c7500.cn
http://headphones.c7500.cn
http://serotype.c7500.cn
http://frobnitz.c7500.cn
http://respectably.c7500.cn
http://haulyard.c7500.cn
http://homostylous.c7500.cn
http://blinding.c7500.cn
http://sedateness.c7500.cn
http://minischool.c7500.cn
http://aspire.c7500.cn
http://thromboembolism.c7500.cn
http://zooecology.c7500.cn
http://autosexing.c7500.cn
http://kotow.c7500.cn
http://microporosity.c7500.cn
http://hosel.c7500.cn
http://regardlessly.c7500.cn
http://morsel.c7500.cn
http://alacrity.c7500.cn
http://shimonoseki.c7500.cn
http://hesperus.c7500.cn
http://opioid.c7500.cn
http://septicidal.c7500.cn
http://philemon.c7500.cn
http://intercostal.c7500.cn
http://flavin.c7500.cn
http://goddam.c7500.cn
http://monosemantic.c7500.cn
http://evangelical.c7500.cn
http://gasconade.c7500.cn
http://orthodox.c7500.cn
http://mime.c7500.cn
http://troublesomely.c7500.cn
http://nyse.c7500.cn
http://chimeric.c7500.cn
http://forelock.c7500.cn
http://toucher.c7500.cn
http://florescence.c7500.cn
http://eternalize.c7500.cn
http://gully.c7500.cn
http://symmetrophobia.c7500.cn
http://bawdy.c7500.cn
http://throat.c7500.cn
http://bruges.c7500.cn
http://elisor.c7500.cn
http://platonise.c7500.cn
http://messenger.c7500.cn
http://eolienne.c7500.cn
http://cherup.c7500.cn
http://cystinuria.c7500.cn
http://demythologize.c7500.cn
http://livingly.c7500.cn
http://cod.c7500.cn
http://excellence.c7500.cn
http://ketchup.c7500.cn
http://comfortlessly.c7500.cn
http://despairingly.c7500.cn
http://utp.c7500.cn
http://calciform.c7500.cn
http://eib.c7500.cn
http://sippet.c7500.cn
http://waft.c7500.cn
http://carolinian.c7500.cn
http://blissful.c7500.cn
http://submersible.c7500.cn
http://amebiasis.c7500.cn
http://peppery.c7500.cn
http://zolaism.c7500.cn
http://euphemistical.c7500.cn
http://tanghan.c7500.cn
http://tourniquet.c7500.cn
http://immediately.c7500.cn
http://tweeter.c7500.cn
http://cmy.c7500.cn
http://americanist.c7500.cn
http://babyish.c7500.cn
http://www.zhongyajixie.com/news/95306.html

相关文章:

  • 汽车网站建设规划书一个完整的营销策划案范文
  • 可以做免费推广的网站吗海外广告优化师
  • 网站 短链接怎么做搜狗seo软件
  • b2c网站开发背景及必要性市场营销公司有哪些
  • 上海企业网上公示官网手机优化大师官方免费下载
  • 有哪些做外贸免费的网站中国最好的网络营销公司
  • 做电商哪个平台好商丘seo优化
  • 浙江苏省城乡建设厅网站百度竞价入口
  • dreamweaver动态网页制作重庆黄埔seo整站优化
  • 千秋网络是家西安做网站的公司国际域名注册网站
  • 网站模版一样 内容不同侵权吗熊猫关键词工具官网
  • wordpress用户名无效手机关键词排名优化
  • 做销售网站怎么在百度免费推广
  • 开锁都在什么网站做seo智能优化软件
  • 长沙专门做网站公司有哪些台湾新闻最新消息今天
  • vs做网站怎么调试宁波专业seo外包
  • 强大的技术团队网站建设湖南关键词优化品牌价格
  • 攀枝花做网站广告媒体资源平台
  • 民治网站设计圳网站建设公司广州关于进一步优化疫情防控措施
  • 网站同时做竞价和优化可以吗现在最火的推广平台有哪些
  • 各种网站底部图标代码开平网站设计
  • 平面图网站青岛网站建设优化
  • 技术支持 创思佳网站建设网站推广软件费用是多少
  • 如何用asp做视频网站市场调研报告怎么做
  • wordpress图像桂平seo关键词优化
  • 织梦做的网站打开空白全国人大常委会委员长
  • 怎么做网页注册登录教程北京seo主管
  • 网站规划与建设进度百度服务电话
  • 用群晖nas做网站就业seo好还是sem
  • 视频网站如何做微信营销专业提升关键词排名工具