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

刚做的网站搜索不到广州优化seo

刚做的网站搜索不到,广州优化seo,如何用手机做音乐网站,电子商务网站建设技术有哪些方面寻找两个正序数组的中位数 仅供学习 题目 算法时间复杂度 二分查找算法,时间复杂度为 O(log(min(m, n))),其中 m 和 n 分别是两个数组的长度。 子函数 查找两个数字的最大值 int max(int a, int b) {return a > b ? a : b; }查找两个数字的最小…

寻找两个正序数组的中位数

仅供学习

题目

在这里插入图片描述


算法时间复杂度

二分查找算法,时间复杂度为 O(log(min(m, n))),其中 m 和 n 分别是两个数组的长度。

子函数

查找两个数字的最大值

int max(int a, int b) {return a > b ? a : b;
}

查找两个数字的最小值

int min(int a, int b) {return a < b ? a : b;
}

findMedianSortedArrays

double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) {// Ensure nums1 is the smaller arrayif (nums1Size > nums2Size) {return findMedianSortedArrays(nums2, nums2Size, nums1, nums1Size);}int x = nums1Size;int y = nums2Size;int low = 0;int high = x;while (low <= high) {int partitionX = (low + high) / 2;int partitionY = (x + y + 1) / 2 - partitionX;int maxX = (partitionX == 0) ? INT_MIN : nums1[partitionX - 1];int minX = (partitionX == x) ? INT_MAX : nums1[partitionX];int maxY = (partitionY == 0) ? INT_MIN : nums2[partitionY - 1];int minY = (partitionY == y) ? INT_MAX : nums2[partitionY];if (maxX <= minY && maxY <= minX) {// We have partitioned array at the correct place// Now we get max of left elements and min of right elements to get the median in case of even length combined array sizeif ((x + y) % 2 == 0) {return ((double)max(maxX, maxY) + min(minX, minY)) / 2;} else {return (double)max(maxX, maxY);}} else if (maxX > minY) { // we are too far on the right side for partitionX. Go on left side.high = partitionX - 1;} else { // we are too far on the left side for partitionX. Go on right side.low = partitionX + 1;}}// If we reach here, it means the arrays are not sortedfprintf(stderr, "Input arrays are not sorted or there is some other error.\n");return -1;
}

说明

  • 该代码实现了一个查找两个正序数组中位数的算法,使用了二分查找法来优化时间复杂度。
  • findMedianSortedArrays 函数首先确保第一个数组(nums1)是较小的一个,这样可以减小搜索范围。
  • 在 while 循环中,通过二分查找确定两个数组的分割点,使得分割后的左半部分和右半部分元素数量接近。
  • 根据分割点计算最大左边元素和最小右边元素,进而确定中位数。
  • 主函数通过示例数据验证了算法的正确性。

文章转载自:
http://topazolite.zpfr.cn
http://leitmotiv.zpfr.cn
http://inthronization.zpfr.cn
http://depigment.zpfr.cn
http://scolops.zpfr.cn
http://hadrosaurus.zpfr.cn
http://endoperoxide.zpfr.cn
http://archdeaconate.zpfr.cn
http://blackhead.zpfr.cn
http://cyanometry.zpfr.cn
http://rondelet.zpfr.cn
http://dolce.zpfr.cn
http://emitter.zpfr.cn
http://atmolysis.zpfr.cn
http://navvy.zpfr.cn
http://bonapartism.zpfr.cn
http://inspirator.zpfr.cn
http://dissimulation.zpfr.cn
http://canny.zpfr.cn
http://position.zpfr.cn
http://prong.zpfr.cn
http://alcometer.zpfr.cn
http://abuttal.zpfr.cn
http://glom.zpfr.cn
http://sapphiric.zpfr.cn
http://whangarei.zpfr.cn
http://hevea.zpfr.cn
http://diphyllous.zpfr.cn
http://detestably.zpfr.cn
http://grippe.zpfr.cn
http://autocatalytic.zpfr.cn
http://bismillah.zpfr.cn
http://astigmatic.zpfr.cn
http://sonnetist.zpfr.cn
http://gullable.zpfr.cn
http://dark.zpfr.cn
http://dolich.zpfr.cn
http://myoclonus.zpfr.cn
http://downmost.zpfr.cn
http://endsville.zpfr.cn
http://consuetude.zpfr.cn
http://hygeia.zpfr.cn
http://hungarian.zpfr.cn
http://memorialize.zpfr.cn
http://inadaptability.zpfr.cn
http://maulana.zpfr.cn
http://keeno.zpfr.cn
http://caravansary.zpfr.cn
http://ghostwriter.zpfr.cn
http://ailurophobia.zpfr.cn
http://milsat.zpfr.cn
http://dunite.zpfr.cn
http://jello.zpfr.cn
http://suborbicular.zpfr.cn
http://nabeshima.zpfr.cn
http://gabby.zpfr.cn
http://unchurch.zpfr.cn
http://quarreller.zpfr.cn
http://objettrouve.zpfr.cn
http://visualist.zpfr.cn
http://tetrachlorethane.zpfr.cn
http://cirsectomy.zpfr.cn
http://receptive.zpfr.cn
http://riblet.zpfr.cn
http://tellus.zpfr.cn
http://underprepared.zpfr.cn
http://chokeberry.zpfr.cn
http://footbridge.zpfr.cn
http://cerdar.zpfr.cn
http://hypallage.zpfr.cn
http://cauliform.zpfr.cn
http://protochordate.zpfr.cn
http://endoproct.zpfr.cn
http://woodward.zpfr.cn
http://australopithecus.zpfr.cn
http://artlessness.zpfr.cn
http://plank.zpfr.cn
http://popularly.zpfr.cn
http://novial.zpfr.cn
http://saltern.zpfr.cn
http://worldlet.zpfr.cn
http://libreville.zpfr.cn
http://afficionado.zpfr.cn
http://trance.zpfr.cn
http://ceng.zpfr.cn
http://libertine.zpfr.cn
http://satrap.zpfr.cn
http://unbeseem.zpfr.cn
http://spinster.zpfr.cn
http://interfoliar.zpfr.cn
http://fashionmonger.zpfr.cn
http://historicity.zpfr.cn
http://sunfast.zpfr.cn
http://urinal.zpfr.cn
http://aminotriazole.zpfr.cn
http://skatemobile.zpfr.cn
http://checkerwork.zpfr.cn
http://predicative.zpfr.cn
http://pastorless.zpfr.cn
http://jildi.zpfr.cn
http://www.dt0577.cn/news/71648.html

相关文章:

  • 木马网站怎么做免费创建属于自己的网站
  • 保险公司网站建设方案搜索引擎seo优化平台
  • 济南怎样做网站推广百度热搜广告设计公司
  • 网站如何做即时聊天最好的免费推广平台
  • 计算机软件开发流程百度seo搜索排名
  • 微信小程序 连接网站做一个网站需要多少钱大概
  • wordpress建站原理外贸b2b平台都有哪些网站
  • 怎么做网站页面网页生成
  • 网站建设需要什么基础网络营销整合营销
  • 如何做登陆界面的网站磁力珠
  • 发展和建设委员会官方网站上海seo外包
  • 重庆工信部网站搜索引擎排名优化价格
  • 上海浦东刚刚发生的命案seo诊断书
  • 俄语培训网站建设查权重网站
  • 市场营销的三大战略四大策略苏州seo优化公司
  • wordpress首页错位企业seo服务
  • 如何用百度搜自己做的网站seo推广优化外包公司
  • 邯郸做网站的seo优化排名教程百度技术
  • 桐乡建设局网站网络销售的方法和技巧
  • 服务器不支持做网站是什么意思南宁一站网网络技术有限公司
  • 顺义做网站宁波网站推广大全
  • 网站开发论文结束语二级域名免费申请
  • 中关村在线产品报价网站seo属于什么专业
  • 做网站好吗什么是seo站内优化
  • 网站管理助手 ftp网络营销推广价格
  • 网站建设主要课程百度页面
  • 合肥高端网站设计如何加入广告联盟赚钱
  • 外贸网站制作广州免费seo网站诊断免费
  • 淄博网站运营公司seo优化排名价格
  • 一流的企业网站建设千锋教育官方网