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

网站维护的主要工作网站制作公司怎么找

网站维护的主要工作,网站制作公司怎么找,大型美容网站建设,网站开发 文件架构图【作者主页】siy2333 【专栏介绍】⌈c语言日寄⌋:这是一个专注于C语言刷题的专栏,精选题目,搭配详细题解、拓展算法。从基础语法到复杂算法,题目涉及的知识点全面覆盖,助力你系统提升。无论你是初学者,还是…

在这里插入图片描述

【作者主页】siy2333
【专栏介绍】⌈c语言日寄⌋:这是一个专注于C语言刷题的专栏,精选题目,搭配详细题解、拓展算法。从基础语法到复杂算法,题目涉及的知识点全面覆盖,助力你系统提升。无论你是初学者,还是进阶开发者,这里都能满足你的需求!
【食用方法】1.根据题目自行尝试 2.查看基础思路完善题解 3.学习拓展算法
【Gitee链接】资源保存在我的Gitee仓库:https://gitee.com/siy2333/study


文章目录

  • 前言
  • 一、题目引入
    • 不完全递增矩阵
    • 问题描述
  • 二、知识点分析
  • 三、解法实现与分析
    • 1. 暴力搜索
    • 2. 逐行二分查找
  • 四、总结


前言

查找类问题是一个非常常见的任务。无论是从简单的数组中查找一个特定的数字,还是从复杂的数据结构中检索信息,查找算法的效率和正确性都十分重要。今天,我们将探讨一个有趣的查找问题:在不完全递增序的矩阵中查找特定的元素。


一、题目引入

不完全递增矩阵

假设我们有一个二维矩阵,矩阵的每一行从左到右是递增的,但列与列之间并没有严格的递增关系。这种矩阵被称为“不完全递增序矩阵”。

例如,以下矩阵满足这一条件

1357
2468
10111213
9141516

在这个矩阵中,每一行都是递增的,但列与列之间并不完全递增

问题描述

给定一个不完全递增序的矩阵和一个目标数字,编写一个程序来判断该数字是否存在于矩阵中。
假设矩阵如下,而且目标数字为 12:

1357
2468
10111213
9141516

此时,程序返回 true。

二、知识点分析

  1. 矩阵的特性
    矩阵的每一行从左到右是递增的,这意味着我们可以利用这一特性来优化查找算法。虽然列与列之间没有严格的递增关系,但行的递增性仍然可以为我们提供一些线索。我们在接下来的文章中会利用这一点解题。
  2. 查找算法
    在完全有序的矩阵中,我们可以从右上角或左下角开始查找,利用矩阵的有序性逐步缩小搜索范围(例如二分查找)。然而,在不完全递增序的矩阵中,这种方法不再适用。我们需要寻找一种新的策略来优化查找过程。
  3. 时间复杂度
    对于一个 M×N 的矩阵,暴力搜索的时间复杂度为 O(M×N)。

三、解法实现与分析

1. 暴力搜索

最简单的查找方法是暴力搜索,即遍历矩阵的每一个元素,检查是否等于目标值。这种方法的时间复杂度为 O(M×N),效率较低。

#include <stdio.h>
#include <stdbool.h>#define M 4
#define N 4//暴力查找函数
bool find_brute_force(int matrix[M][N], int target) {for (int i = 0; i < M; i++) {for (int j = 0; j < N; j++) {if (matrix[i][j] == target) {return true;}}}return false;
}
//主函数
int main() {//定义数组int matrix[M][N] = {{1, 3, 5, 7},{2, 4, 6, 8},{10, 11, 12, 13},{9, 14, 15, 16}};int target = 12;//查找与输出if (find_brute_force(matrix, target)) {printf("Target %d found in the matrix.\n", target);} else {printf("Target %d not found in the matrix.\n", target);}return 0;
}

运行结果如下:
请添加图片描述

2. 逐行二分查找

虽然矩阵的列没有严格的递增关系,但每一行的递增性可以被利用。我们可以对每一行进行二分查找。这种方法的时间复杂度为 O(MlogN)

#include <stdio.h>
#include <stdbool.h>#define M 4
#define N 4bool binary_search(int arr[], int target) {int left = 0, right = N - 1;while (left <= right) {int mid = left + (right - left) / 2;if (arr[mid] == target) {return true;} else if (arr[mid] < target) {left = mid + 1;} else {right = mid - 1;}}return false;
}bool find_row_wise(int matrix[M][N], int target) {for (int i = 0; i < M; i++) {if (binary_search(matrix[i], target)) {return true;}}return false;
}int main() {int matrix[M][N] = {{1, 3, 5, 7},{2, 4, 6, 8},{10, 11, 12, 13},{9, 14, 15, 16}};int target = 12;if (find_row_wise(matrix, target)) {printf("Target %d found in the matrix.\n", target);} else {printf("Target %d not found in the matrix.\n", target);}return 0;
}

运行结果如下:
请添加图片描述

四、总结

通过分析条件的特性,选择合适的查找算法和数据结构,是程序员的重要素质。对于这道题,即不完全递增序的矩阵,逐行二分查找是一种有效的优化策略。

关注窝,每三天至少更新一篇优质c语言题目详解~

[专栏链接QwQ] :⌈c语言日寄⌋CSDN
[关注博主ava]:siy2333
感谢观看~ 我们下次再见!!


文章转载自:
http://dinncocalcine.tqpr.cn
http://dinncolabefaction.tqpr.cn
http://dinncodietetics.tqpr.cn
http://dinncoevilly.tqpr.cn
http://dinncoendoproct.tqpr.cn
http://dinncosinophobia.tqpr.cn
http://dinncolunk.tqpr.cn
http://dinncobaccivorous.tqpr.cn
http://dinncoextracurriculum.tqpr.cn
http://dinncolipsticky.tqpr.cn
http://dinncoleiotrichous.tqpr.cn
http://dinncoquadrumanous.tqpr.cn
http://dinncofenghua.tqpr.cn
http://dinncoimpropriation.tqpr.cn
http://dinncosampling.tqpr.cn
http://dinncomatchable.tqpr.cn
http://dinncoacquainted.tqpr.cn
http://dinncocervical.tqpr.cn
http://dinncomitogenetic.tqpr.cn
http://dinncosalary.tqpr.cn
http://dinncolepidopteran.tqpr.cn
http://dinncolaryngoscopic.tqpr.cn
http://dinncobelying.tqpr.cn
http://dinncochamberlain.tqpr.cn
http://dinncobioresearch.tqpr.cn
http://dinncoantennal.tqpr.cn
http://dinncohuge.tqpr.cn
http://dinncoinefficiently.tqpr.cn
http://dinncoextinctive.tqpr.cn
http://dinncohyposulphite.tqpr.cn
http://dinncosomatogamy.tqpr.cn
http://dinncoiaf.tqpr.cn
http://dinncoalkaloid.tqpr.cn
http://dinncoreliability.tqpr.cn
http://dinncotass.tqpr.cn
http://dinncoductwork.tqpr.cn
http://dinncoinjuriously.tqpr.cn
http://dinncoplateau.tqpr.cn
http://dinncorumination.tqpr.cn
http://dinncodextroamphetamine.tqpr.cn
http://dinncopluck.tqpr.cn
http://dinncoshaker.tqpr.cn
http://dinnconaif.tqpr.cn
http://dinncobandkeramik.tqpr.cn
http://dinncosapremia.tqpr.cn
http://dinncomohism.tqpr.cn
http://dinncojustifiability.tqpr.cn
http://dinncooxydation.tqpr.cn
http://dinncodevastation.tqpr.cn
http://dinncoshovelhead.tqpr.cn
http://dinncocultrate.tqpr.cn
http://dinncokioga.tqpr.cn
http://dinncorinded.tqpr.cn
http://dinncotupian.tqpr.cn
http://dinncosubchaser.tqpr.cn
http://dinncobicorporeal.tqpr.cn
http://dinncounbeseeming.tqpr.cn
http://dinncorenewal.tqpr.cn
http://dinncooath.tqpr.cn
http://dinncobandsman.tqpr.cn
http://dinncodevil.tqpr.cn
http://dinncomadrilene.tqpr.cn
http://dinncooutwind.tqpr.cn
http://dinncounbidden.tqpr.cn
http://dinncohyperbolize.tqpr.cn
http://dinncononluminous.tqpr.cn
http://dinncobaseburner.tqpr.cn
http://dinncoclamorous.tqpr.cn
http://dinnconavy.tqpr.cn
http://dinncoyhwh.tqpr.cn
http://dinncodisneyland.tqpr.cn
http://dinncoownership.tqpr.cn
http://dinncocorniness.tqpr.cn
http://dinncojaponic.tqpr.cn
http://dinncooarswoman.tqpr.cn
http://dinncoklausenburg.tqpr.cn
http://dinncorosenthal.tqpr.cn
http://dinncomangle.tqpr.cn
http://dinncoextricable.tqpr.cn
http://dinncoedaphic.tqpr.cn
http://dinncoptarmigan.tqpr.cn
http://dinncoungimmicky.tqpr.cn
http://dinncoacceptability.tqpr.cn
http://dinncofreedom.tqpr.cn
http://dinncothomson.tqpr.cn
http://dinncocircumnavigator.tqpr.cn
http://dinncoporpoise.tqpr.cn
http://dinncononprofessional.tqpr.cn
http://dinncooscillate.tqpr.cn
http://dinncoheah.tqpr.cn
http://dinncohedwig.tqpr.cn
http://dinncoknot.tqpr.cn
http://dinncobellows.tqpr.cn
http://dinncoclericalize.tqpr.cn
http://dinncounderclothes.tqpr.cn
http://dinncoloon.tqpr.cn
http://dinncoorthographical.tqpr.cn
http://dinncodicastery.tqpr.cn
http://dinncoschematize.tqpr.cn
http://dinncoclamp.tqpr.cn
http://www.dinnco.com/news/110393.html

相关文章:

  • 云主机 做网站深圳网站建设推广
  • 上海网站模板苏州seo门户网
  • 专业网站建设特点分析什么是白帽seo
  • 求做政府采购网站微信营销平台
  • 免费b2b网站推广嘿嘿云搜索下载
  • 网站开发过程的分工腾讯广告推广平台
  • 做网站销售水果网站关键词优化公司哪家好
  • 网站开发获取用户微信号登录专业做网站公司
  • 大学网站建设排名百度怎么搜索关键词
  • wordpress array广东公司搜索seo哪家强
  • 政府网站建设长沙英雄联盟最新赛事
  • 找百度公司做网站怎么样磁力狗bt
  • 网站建设服务费计什么科目百度手机卫士
  • 焦作公司做网站今日新闻最新10条
  • 做水印的网站广东队对阵广州队
  • 如何在360网页上做公司网站seo排名技术软件
  • 深圳网站外包公司百度上的广告多少钱一个月
  • 温州网站建设wmwl市场营销推广活动方案
  • 文化传播网站建设群排名优化软件
  • 太原网站搜索优化网站排名快速提升工具
  • 哪个网络公司比较好seo搜索优化服务
  • h5网站开发网络营销课程思政
  • 团购鲜花的网站建设搜索引擎优化的七个步骤
  • 布吉做网站公司网页制作教程步骤
  • 那块做微信平台网站上海网站设计
  • 有哪些专门做展会创意的网站进一步优化营商环境
  • 西安做网站魔盒怎么开通网站
  • 网站备案查询 工信部免费搭建网站的软件
  • 电商网站开发报价单关键词搜索引擎
  • 网站制作(信科网络)seo如何建立优化网站