算法导论 算法

Algorithms are an integral part of the development world. Before starting coding of any software first an effective algorithm is designed to get desired outputs. In this article, we will understand what are algorithms, characteristics of algorithms, some examples of famous algorithms, Types of algorithms etc..

算法是开发领域不可或缺的一部分。 在开始对任何软件进行编码之前,必须先设计一种有效的算法以获得所需的输出。 在本文中,我们将了解什么是算法,算法的特征,著名算法的一些示例,算法的类型等。

Let's get started...

让我们开始吧...

什么是算法? (What is an Algorithm?)

It is a combination of a sequence of finite steps to solve a particular problem. or, It is a well-defined procedure which takes zero or more input and must produce at least one output to solve a particular problem.

它是解决特定问题的一系列有限步骤的组合。 或者,这是一个定义明确的过程,需要零个或多个输入,并且必须产生至少一个输出才能解决特定问题。

算法的特性/特征 (Properties/Characteristics of Algorithms)

  • Input: It may take zero or more input.

    输入:可能需要零个或多个输入。

  • Output: It must produce at least one output.

    输出:它必须产生至少一个输出。

  • Definiteness (Unambiguous): Every step in algorithm should be well defined, unique, precise.

    确定性(明确):算法中的每个步骤都应定义明确,唯一,精确。

  • Finiteness (Limited): Every algorithm should contain a finite number of steps and should produce a result infinite amount of time.

    有限(有限):每种算法都应包含有限数量的步骤,并且应产生无限长的时间。

  • Effectiveness: Operations used in algorithm must be simple and easy to understand.

    有效性:算法中使用的运算必须简单易懂。

  • Language independent.

    语言无关。

Note:

注意:

  • An algorithm is a step by step procedure to solve a particular problem whereas a program is an algorithm that is encoded in any programming language.

    算法是解决特定问题的逐步过程,而程序是以任何编程语言编码的算法。

  • Program is language dependent and algorithm is language independent.

    程序与语言有关,而算法与语言无关。

算法符号 (Notation of an Algorithm)

  1. Name of the algorithm: It should specify the problem to be solved.

    算法名称:应该指定要解决的问题。

  2. Step no.: It is an identification tag ( step numbering ) that specify the numbering of steps/statements. It is a positive integer.

    步骤编号:这是一个标识标签(步骤编号),用于指定步骤/语句的编号。 它是一个正整数。

  3. Explanatory comments: It is used to specify the meaning of instruction that is used in the algorithm. It is used to understand the logic of operations by the use of [ ] for comments in the algorithm.

    解释性注释:它用于指定算法中使用的指令的含义。 通过在算法中使用[]进行注释,可以理解操作的逻辑。

  4. Termination: Generally it is a STOP statement and the last statement of an algorithm that denoted ending of the algorithm.

    终止:通常,它是STOP语句,并且是算法的最后一条语句,表示该算法的结尾。

.minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } }

例 (Example)

Algorithm for addition of two numbers:

两个数相加的算法:

    ADD( A , B )
Step 1: Read A,B
Step 2: sum=A+B [ A & B are added and their value is stored in sum ]
Step 3: PRINT ‘Sum of A & B =’, sum
Step 4: STOP

This is an algorithm, the corresponding program will be different for different languages like for C language it is:

这是一种算法,不同的语言(例如C语言)的相应程序将有所不同:

#include<stdio.h>
int main()
{int num1,num2,opt;
printf("Enter the first Integer:\n");
scanf("%d",&num1);
printf("Enter the second Integer:\n");
scanf("%d",&num2);
printf("Enter an correct option -> 1:addition 2: subtraction 3: multiplication 4: division -> \n");
scanf("%d",&opt);
switch(opt)
{case 1:
printf("\nAddition of  %d and %d is: %d",num1,num2,num1+num2);
break;
case 2:
printf("\nSubstraction of %d  and %d is:  %d",num1,num2,num1-num2);
break;
case 3:
printf("\nMultiplication of %d  and %d is:  %d",num1,num2,num1*num2);
break;
case 4:
if(num2==0)
{printf("OOps Devide by zero\n");
}
else
{printf("\n Division of %d  and %d is:  %d",num1,num2,num1/num2);
}
break;
default:
printf("\n Enter correct option\n");
}
return 0;
}

Output

输出量

Enter the first Integer: 10
Enter the second Integer: 20
Enter an correct option -> 1:addition 2: subtraction 3: multiplication 4: division ->  3Multiplication of 10  and 20 is:  200

算法类型 (Types of Algorithm)

  1. Divide and conquer algorithm

    分而治之算法

  2. Greedy algorithm

    贪心算法

  3. Dynamic programming

    动态编程

  4. Branch and bound algorithm

    分支定界算法

  5. Back Tracking

    回溯

  6. Simple Recursive algorithm

    简单递归算法

  7. Randomized algorithm

    随机算法

  8. Brute force algorithm

    蛮力算法

This was just the basic understanding of algorithm world. Read more articles/tutorials on Algorithms.

这只是对算法世界的基本了解。 阅读有关算法的更多文章/教程 。

翻译自: https://www.includehelp.com/algorithms/introduction-to-algorithms.aspx

算法导论 算法

算法导论 算法_算法导论相关推荐

  1. 排序算法的时间复杂度_算法的时间复杂度

    一. 算法的时间复杂度 1.如何评估算法的性能 数据结构和算法,本质上是解决现实存在的问题,即如何让解决指定问题的代码运行得更快?一个算法如果能在所要求的资源限制(resource constrain ...

  2. moead算法流程步骤_算法——抓住程序的灵魂

    做任何事情都要有一定的步骤,为了解决一个问题而采取的方法和步骤就称为算法.C语言的算法是计算机算法,即计算机能够执行的算法.只有明确了算法后,才能使应用程序实现某些功能.所以,通常人们会将算法称为程序 ...

  3. python算法工程师书籍_算法工程师路线图(经验浓缩,纯干货!)

    说起算法(Algorithm),需要值得注意的是,数据结构与算法,机器学习算法都可简称为算法,但两者是完全不同的.数据结构与算法是计算机科学中的一门基础课程,主要内容是关于如何设计计算机程序,使得程序 ...

  4. 机器学习导论�_机器学习导论

    机器学习导论� Say you are practising basketball on your own and you are trying to shoot the ball into the ...

  5. 分支限界算法c语言_算法学习计划

    学习计划 根据王红梅编著的<算法设计与分析>,读取每一章的内容,然后从乐扣上找对应的算法题,包含简单-中等-困难三种程度.尽量每两周能够完成一章.遇到一种类型的问题时,先自己想想解决方案, ...

  6. a*算法的时间复杂度_算法基础——时间复杂度amp;空间复杂度

    关注.星标公众号,学点计算机知识. 整理:persistenceBin 今天来跟大家继续分享一下数据结构的基础知识--算法效率的度量:时间复杂度和空间复杂度.首先来跟大家分享一下在电影<复仇者联 ...

  7. a*算法迷宫 c++_算法竞赛专题解析(12):搜索基础

    搜索 搜索,就是查找解空间,它是"暴力法"算法思想的具体实现. 文章目录: 01 搜索简介 02 搜索算法的基本思路 03 BFS的性质和代码实现 04 DFS的常见操作和代码实现 ...

  8. a*算法的时间复杂度_算法的时间和空间复杂度,就是这么简单

    算法(Algorithm) 算法是程序用来操作数据.解决程序问题的一组方法.对于同一个问题,使用不同的算法,也许最终得到的结果是一样的,但在过程中消耗的资源和时间却会有很大的区别. 那么我们应该如何去 ...

  9. 简述isodata算法的原理_算法常见面试题汇总(一):概率论与数理统计部分

    初级或中级算法岗面试题主要有四类:数理统计基础.机器学习模型原理.编程能力.项目经验.项目经验因人而异,所以仅总结前三个方面的基础知识,分享给朋友.(高级或资深算法岗面试内容不在本文范围内) 1.大数 ...

  10. c++矩阵连乘的动态规划算法并输出_算法面试必修课,动态规划基础题型归纳(三)

    动态规划(Dynamic Programming,简称DP),是大家都觉得比较难以掌握的算法.为了应付面试,我们经常会背诵一下DP问题的源码,其实,只要理解了思想,掌握基本的模型,然后再来点写代码的套 ...

最新文章

  1. tf.squeeze示例代码
  2. ICCV2021|一种用于解决点云场景中同类对象分割的网络
  3. opencv计算brox光流_字节跳动计算机视觉算法实习生视频面试
  4. 创建世界级品牌的大师忠告
  5. Python数据预处理:使用Dask和Numba并行化加速
  6. LoRa协议在Arduino上的应用——原理及代码分析(二)
  7. win10隐藏桌面功能
  8. CentOS 7 yum update 报错 Failed to connect to 2404:6800:4012::200e: Network is unreachable
  9. C++中使用sizeof查看几种数据类型所占内存字节大小
  10. 统一身份认证(CAS)中文文档 请多指教
  11. luogu1378 油滴扩展 (深搜)
  12. 互联网产品的运营指标
  13. kindle paperwhite3 android,Kindle Paperwhite3入手20天感受
  14. css 超出显示省略号
  15. MER:1.8万字带你系统了解宏组学实验与分析(高通量测序应用于病原体和害虫诊断——综述与实用性建议)...
  16. 2021计算机保研|人大高瓴、自动化所、人大信院、南开、天大
  17. Python实现英文文本的LZW编码压缩
  18. 【inotify事件监控工具】
  19. 联想ThinkPad E560 按F5 F6调节屏幕亮度,将调节屏幕亮度的按钮改为fn+F5 F6控制
  20. [语音录制与播放]stm32+adc+dac

热门文章

  1. git version是什么软件_Deepin 15.11 安装 ZoneMinder 视频监控软件
  2. 查python答案的软件-中国大学MOOC的APP慕课用Python玩转数据答案查题公众号
  3. java仿qq gui_Java仿QQ登入页面
  4. go get 的不再src目录中_GO语言基础进阶教程:包的使用
  5. python出现traceback什么意思_python-异常处理 traceback获取详细异常
  6. webpack 读取文件夹下的文件_webpack基本介绍及使用
  7. Java集合:Set集合
  8. 消息队列-Message Queue
  9. org.jeecgframework.core.common.exception.MyExceptionHandler]java.lang.NullPointerException
  10. 用express、mongodb、nodejs开发简单的登陆