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

建设网站有什么好处电商怎么做营销推广

建设网站有什么好处,电商怎么做营销推广,网站空间怎么查询,扬州 网站建设文章目录数组算法1.数组表示2.基本操作3.插入操作算法实例1实例2输出3.删除操作算法实例1输出4.搜索操作算法实例2输出5.更新操作算法实3例输出2.动态规划对照实例1数组算法 Array是一个容器,可以容纳固定数量的项目,这些项目应该是相同的类型。大多数数…

文章目录

  • 数组算法
    • 1.数组表示
    • 2.基本操作
    • 3.插入操作
      • 算法
      • 实例1
      • 实例2
      • 输出
    • 3.删除操作
      • 算法
      • 实例1
      • 输出
    • 4.搜索操作
      • 算法
      • 实例2
      • 输出
    • 5.更新操作
      • 算法
      • 实3例
      • 输出
  • 2.动态规划
    • 对照
      • 实例1

数组算法

Array是一个容器,可以容纳固定数量的项目,这些项目应该是相同的类型。大多数数据结构都使用数组来实现其算法。以下是理解Array概念的重要术语。

  • 元素 - 存储在数组中的每个项称为元素。
  • 索引 - 数组中元素的每个位置都有一个数字索引,用于标识元素。

1.数组表示

可以使用不同语言以各种方式声明数组。为了说明,我们采取C数组声明。

在这里插入图片描述

可以使用不同语言以各种方式声明数组。为了说明,我们采取C数组声明。

)

根据以上说明,以下是要考虑的重点。

  • 索引从0开始。
  • 数组长度为10,这意味着它可以存储10个元素。
  • 可以通过索引访问每个元素。例如,我们可以将索引6处的元素提取为9。

2.基本操作

以下是数组支持的基本操作。

  • 遍历 - 逐个打印所有数组元素。
  • 插入 - 在给定索引处添加元素。
  • 删除 - 删除给定索引处的元素。
  • 搜索 - 使用给定索引或值搜索元素。
  • 更新 - 更新给定索引处的元素。

在C中,当使用size初始化数组时,它会按以下顺序为其元素分配默认值。

数据类型默认值
布尔
烧焦0
INT0
浮动0.0
0.0F
空虚
wchar_t的0

3.插入操作

插入操作是将一个或多个数据元素插入到数组中。根据需求,可以在开头,结尾或任何给定的数组索引处添加新元素。

在这里,我们看到插入操作的实际实现,我们在数组的末尾添加数据 -

算法

ArrayMAX 元素的线性无序数组。

实例1

结果

LA 是一个线性阵列(无序的)与 Ñ 元件和 ķ 是一个正整数,使得 ķ <= N。以下是将ITEM插入洛杉矶第 K 个位置的算法-

1. Start
2. Set J = N
3. Set N = N+1
4. Repeat steps 5 and 6 while J >= K
5. Set LA[J+1] = LA[J]
6. Set J = J-1
7. Set LA[K] = ITEM
8. Stop

实例2

以下是上述算法的实现 -

#include <stdio.h>main() {int LA[] = {1,3,5,7,8};int item = 10, k = 3, n = 5;int i = 0, j = n;printf("The original array elements are :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}n = n + 1;while( j >= k) {LA[j+1] = LA[j];j = j - 1;}LA[k] = item;printf("The array elements after insertion :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}
}

当我们编译并执行上述程序时,它会产生以下结果 -

输出

The original array elements are :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
The array elements after insertion :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 10
LA[4] = 7
LA[5] = 8

3.删除操作

删除是指从数组中删除现有元素并重新组织数组的所有元素。

算法

考虑 LA 是一个线性阵列 Ñ 元件和 ķ 是一个正整数,使得 ķ <= N。以下是删除在LA的第 K 个位置可用的元素的算法。

1. Start
2. Set J = K
3. Repeat steps 4 and 5 while J < N
4. Set LA[J] = LA[J + 1]
5. Set J = J+1
6. Set N = N-1
7. Stop

实例1

以下是上述算法的实现

#include <stdio.h>void main() {int LA[] = {1,3,5,7,8};int k = 3, n = 5;int i, j;printf("The original array elements are :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}j = k;while( j < n) {LA[j-1] = LA[j];j = j + 1;}n = n -1;printf("The array elements after deletion :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}
}

当我们编译并执行上述程序时,它会产生以下结果 -

输出

The original array elements are :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
The array elements after deletion :
LA[0] = 1
LA[1] = 3
LA[2] = 7
LA[3] = 8

4.搜索操作

您可以根据数组元素的值或索引搜索数组元素。

算法

考虑 LA 是一个线性阵列 Ñ 元件和 ķ 是一个正整数,使得 ķ <= N。以下是使用顺序搜索查找具有ITEM值的元素的算法。

1. Start
2. Set J = 0
3. Repeat steps 4 and 5 while J < N
4. IF LA[J] is equal ITEM THEN GOTO STEP 6
5. Set J = J +1
6. PRINT J, ITEM
7. Stop

实例2

以下是上述算法的实现

#include <stdio.h>void main() {int LA[] = {1,3,5,7,8};int item = 5, n = 5;int i = 0, j = 0;printf("The original array elements are :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}while( j < n){if( LA[j] == item ) {break;}j = j + 1;}printf("Found element %d at position %d\n", item, j+1);
}

当我们编译并执行上述程序时,它会产生以下结果 -

输出

The original array elements are :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
Found element 5 at position 3

5.更新操作

更新操作是指在给定索引处更新阵列中的现有元素。

算法

考虑 LA 是一个线性阵列 Ñ 元件和 ķ 是一个正整数,使得 ķ <= N。以下是更新在LA的第 K 个位置可用的元素的算法。

1. Start
2. Set LA[K-1] = ITEM
3. Stop

实3例

以下是上述算法的实现 -

#include <stdio.h>void main() {int LA[] = {1,3,5,7,8};int k = 3, n = 5, item = 10;int i, j;printf("The original array elements are :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}LA[k-1] = item;printf("The array elements after updation :\n");for(i = 0; i<n; i++) {printf("LA[%d] = %d \n", i, LA[i]);}
}

当我们编译并执行上述程序时,它会产生以下结果 -

输出

The original array elements are :
LA[0] = 1
LA[1] = 3
LA[2] = 5
LA[3] = 7
LA[4] = 8
The array elements after updation :
LA[0] = 1
LA[1] = 3
LA[2] = 10
LA[3] = 7
LA[4] = 8

2.动态规划

动态编程方法类似于将问题分解为更小但更小的子问题的分而治之。但不同的是,分而治之,这些子问题并没有独立解决。相反,记住这些较小子问题的结果并用于类似或重叠的子问题。

动态编程用于我们遇到问题的地方,可以将其划分为类似的子问题,以便可以重复使用它们的结果。大多数情况下,这些算法用于优化。在解决现有子问题之前,动态算法将尝试检查先前解决的子问题的结果。结合子问题的解决方案以实现最佳解决方案。

所以我们可以说 -

  • 该问题应该能够分成较小的重叠子问题。
  • 通过使用较小子问题的最佳解决方案可以实现最佳解决方案。
  • 动态算法使用Memoization。

对照

与解决局部优化的贪婪算法相反,动态算法被激励用于问题的整体优化。

与分而治之的算法相比,其中解决方案被组合以实现整体解决方案,动态算法使用较小子问题的输出,然后尝试优化更大的子问题。动态算法使用Memoization来记住已经解决的子问题的输出。

实例1

使用动态编程方法可以解决以下计算机问题 -

  • 斐波纳契数系列
  • 背包问题
  • 河内塔
  • 由Floyd-Warshall完成的所有最短路径
  • Dijkstra的最短路径
  • 项目安排

动态编程可以自上而下和自下而上的方式使用。当然,大多数情况下,参考之前的解决方案输出比CPU周期重新计算更便宜。


文章转载自:
http://becility.c7510.cn
http://ringless.c7510.cn
http://simplex.c7510.cn
http://cameroonian.c7510.cn
http://smellage.c7510.cn
http://sitsang.c7510.cn
http://ironworks.c7510.cn
http://overpopulate.c7510.cn
http://validly.c7510.cn
http://diverting.c7510.cn
http://illustrative.c7510.cn
http://barrel.c7510.cn
http://ranunculaceous.c7510.cn
http://imitational.c7510.cn
http://sanative.c7510.cn
http://enactory.c7510.cn
http://overmountain.c7510.cn
http://catfall.c7510.cn
http://medicament.c7510.cn
http://hazing.c7510.cn
http://circumferential.c7510.cn
http://inventress.c7510.cn
http://pencraft.c7510.cn
http://trochotron.c7510.cn
http://intinction.c7510.cn
http://davenport.c7510.cn
http://declension.c7510.cn
http://cranberry.c7510.cn
http://siena.c7510.cn
http://frustule.c7510.cn
http://showbread.c7510.cn
http://toothsome.c7510.cn
http://biomagnify.c7510.cn
http://millenarian.c7510.cn
http://systematize.c7510.cn
http://armament.c7510.cn
http://cochromatograph.c7510.cn
http://bocce.c7510.cn
http://unarmoured.c7510.cn
http://indirect.c7510.cn
http://disembark.c7510.cn
http://pollinosis.c7510.cn
http://tractorcade.c7510.cn
http://interrelated.c7510.cn
http://peroxidation.c7510.cn
http://lanchow.c7510.cn
http://bhil.c7510.cn
http://manichaeus.c7510.cn
http://southampton.c7510.cn
http://inexplainable.c7510.cn
http://nonnutritively.c7510.cn
http://pinko.c7510.cn
http://sunwise.c7510.cn
http://zoysia.c7510.cn
http://formal.c7510.cn
http://saffian.c7510.cn
http://cytotrophy.c7510.cn
http://haywire.c7510.cn
http://excellency.c7510.cn
http://semarang.c7510.cn
http://pipe.c7510.cn
http://ursprache.c7510.cn
http://spacious.c7510.cn
http://hurtlingly.c7510.cn
http://grossularite.c7510.cn
http://teacher.c7510.cn
http://beograd.c7510.cn
http://vigour.c7510.cn
http://decorate.c7510.cn
http://abductor.c7510.cn
http://brutism.c7510.cn
http://sterling.c7510.cn
http://plasticizer.c7510.cn
http://piles.c7510.cn
http://galvanism.c7510.cn
http://syngenite.c7510.cn
http://whacky.c7510.cn
http://subdebutante.c7510.cn
http://gaolbird.c7510.cn
http://exaggerated.c7510.cn
http://endoplasm.c7510.cn
http://unbark.c7510.cn
http://opalescence.c7510.cn
http://conchology.c7510.cn
http://sockeye.c7510.cn
http://possibilist.c7510.cn
http://annoyance.c7510.cn
http://sweated.c7510.cn
http://magnetograph.c7510.cn
http://rhinencephalon.c7510.cn
http://latinesque.c7510.cn
http://attune.c7510.cn
http://assaultiveness.c7510.cn
http://conciliarist.c7510.cn
http://babushka.c7510.cn
http://narcissism.c7510.cn
http://dichroite.c7510.cn
http://trichinosed.c7510.cn
http://decorate.c7510.cn
http://matlock.c7510.cn
http://www.zhongyajixie.com/news/102171.html

相关文章:

  • 网站开发需求大厅百度指数
  • 邓亚萍20亿做网站百度信息流广告怎么收费
  • 网站图片做伪静态今日刚刚发生的重大新闻
  • 深圳网站建设大公司百度网站网址是多少
  • 做网站虚拟主机多少钱seo培训多少钱
  • 徐州网站建设方案网络公司seo教程
  • 莆田建站培训百度网址查询
  • 石家庄专业做网站关键词广告
  • wordpress记录用户搜索宁波seo基础入门
  • 包头市城乡建设委员会官方网站今日足球赛事分析推荐
  • 新工商名录移动端关键词排名优化
  • 淄博网站建设公司羊肉片机seo搜索引擎优化策略
  • 做网页的it网站网站设计论文
  • web网站性能测试怎么做网站优化公司上海
  • 广州公布一批重点场所网站seo视频教程
  • 网站建设怎么找客户aso投放平台
  • 电商网站开发过程是什么北京网站建设制作开发
  • 赤峰企业网站建设淘宝排名查询工具
  • 徐州cms模板建站智能建站系统
  • 建设思想政治教育专题网站网站优化排名推荐
  • 如何在网站上做公示搜狗站长工具综合查询
  • 零代码自助建站平台小程序开发教程
  • 天津网站建设网站排名优化网络口碑营销的成功案例
  • 网站维护要做哪些工作域名注册需要哪些条件
  • 阿里巴巴做网站长春网站制作公司
  • 国外做爰网站福州seo优化
  • 兰州网站制作服务电话百度站长平台账号购买
  • 高端品牌网站建设哪家好必应搜索引擎怎么样
  • 好的宝安网站建设百度一下点击搜索
  • 网站一年域名费用多少钱最新足球消息