算法和编程之间有什么联系? [英] what is the connection between algorithm and programming?

查看:292
本文介绍了算法和编程之间有什么联系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上我很困惑如何将算法用于编程语言?这真让我困惑。学习编程算法真的很重要吗?这是非常有用的吗?

Hi, actually I'm confused how to use algorithm to a programming language? this is really make me confused. is that really important to learn algorithm for programming? and is that really useful?

推荐答案

首先回答你的最后两个问题:

是。

和是的。



问题在于这是一个复杂的领域,很难解释为什么算法在小文本框中很重要。



算法和编程之间存在关系,但它并不总是显而易见的,因为算法与代码无关 - 它与你的程序代码不一定非常相似。

算法是解决问题的过程或公式。 (whatis.com,通过谷歌) 但它更像是一个过程而不是明显代码的过程,虽然您可以查看代码并查看其背后的算法,它并不总是那么容易。



让我们回想起现实世界中算法的含义。

假设你正在开车,你得到了一个刺。显而易见的事情是将穿孔轮胎更换为备用轮胎。因此解决问题的算法我不能从这里到达B点,因为我的轮胎是平的可能是:

To answer your last two questions first:
Yes.
And Yes.

The trouble is that this is a complicated area, and it's difficult to explain why algorithms are important in a small text box.

There is a relationship between algorithms and programming, but it's not always obvious because an algorithm is code independent - it doesn't resemble your "program code" necessarily that closely.
An algorithm is "a procedure or formula for solving a problem." (whatis.com, via Google) but it's more of a process than something that is obviously code, and while you can look at code and see the algorithm behind it sometimes, it's not always that easy.

Let's back up and think of what an algorithm is in the real world.
Suppose you are driving along, and you get a puncture. The obvious thing to do is to swap the punctured tyre for the spare. So the algorithm for solving your problem "I can't get from here to point B because my tyre is flat" could be:
Remove spare wheel from car.
Remove jack and wheel brace from car.
Use the jack and wheel brace to remove the wheel that has the flat tyre.
Use the wheel brace to fit the spare tire.
Put the jack, wheel brace, and punctured tyre in back in the car.



但要在指示中实施,那些从未尝试过改变的人轮胎将能够遵循(同样为什么计算机必须跟随代码中的指令)要复杂得多:你可能会遇到更多的步骤,几个条件和循环结构,以及更精确。

例如,上述算法的第一步可能从以下开始:


But to implement that in instructions that someone who has never tried to change a tyre will be able to follow (in the same why that a computer has to "follow" the instructions in your code) is a lot more complex: you will probably have a heck of a lot more steps, several conditional and loop constructs, and a lot more precision.
For example, the first step of the algorithm above will probably start with:

Boot.Open();
if (!Boot.Contains("Spare Tyre") Panic("No spare tyre");
...



算法是过程,编程是实现,它特定于您的编码语言,环境以及应用程序其余部分的工作方式。 />


它们重要吗?是的。如果你不了解基本的东西,你会做出很多错误的决定。例如,如果你不了解Quick如果您需要实现几百万条记录的排序并且只能想到冒泡排序,那么排序你会遇到真正的问题!:笑:


The algorithm is the process, the programming is the implementation, which is specific to your coding language, environment, and how the rest of your app works.

Are they important? Yes. If you don't understand the fundamental stuff, you will make a lot of wrong decisions. For example, if you don't know about Quick Sort you're going to have real problems if you need to implement a sort for a couple of million records and can only think of a Bubble Sort! :laugh:


算法就像一个用于解决问题的收据。

要执行解决问题的程序,请使用该语言翻译算法。
An algorithm is like a receipt to solve a problem.
To do a program that solve the problem, you translate the algorithm in that language.


这篇关于算法和编程之间有什么联系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆