@TODO

2024-01-30 10:50
文章标签 todo

本文主要是介绍@TODO,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

In mathematics and computer science, an algorithm (/ˈælɡərɪðəm/ (listen)) is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing calculations and data processing. More advanced algorithms can perform automated deductions (referred to as automated reasoning) and use mathematical and logical tests to divert the code execution through various routes (referred to as automated decision-making). Using human characteristics as descriptors of machines in metaphorical ways was already practiced by Alan Turing with terms such as “memory”, “search” and “stimulus”.

In contrast, a heuristic is an approach to problem solving that may not be fully specified or may not guarantee correct or optimal results, especially in problem domains where there is no well-defined correct or optimal result.

As an effective method, an algorithm can be expressed within a finite amount of space and time, and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing “output” and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

在这里插入图片描述

Flowchart of an algorithm (Euclid’s algorithm) for calculating the greatest common divisor (g.c.d.) of two numbers a and b in locations named A and B. The algorithm proceeds by successive subtractions in two loops: IF the test B ≥ A yields “yes” or “true” (more accurately, the number b in location B is greater than or equal to the number a in location A) THEN, the algorithm specifies B ← B − A (meaning the number b − a replaces the old b). Similarly, IF A > B, THEN A ← A − B. The process terminates when (the contents of) B is 0, yielding the g.c.d. in A. (Algorithm derived from Scott 2009:13; symbols and drawing style from Tausworthe 1977).

在这里插入图片描述

Ada Lovelace’s diagram from “note G”, the first published computer algorithm

Contents

  • 1 History
  • 2 Informal definition
  • 3 Formalization
  • 4 Expressing algorithms
  • 5 Design
  • 6 Computer algorithms
  • 7 Examples
    • 7.1 Algorithm example
    • 7.2 Euclid's algorithm
      • 7.2.1 Computer language for Euclid's algorithm
      • 7.2.2 An inelegant program for Euclid's algorithm
      • 7.2.3 An elegant program for Euclid's algorithm
    • 7.3 Testing the Euclid algorithms
    • 7.4 Measuring and improving the Euclid algorithms
  • 8 Algorithmic analysis
    • 8.1 Formal versus empirical
    • 8.2 Execution efficiency
  • 9 Classification
    • 9.1 By implementation
    • 9.2 By design paradigm
    • 9.3 Optimization problems
    • 9.4 By field of study
    • 9.5 By complexity
    • 9.6 Continuous algorithms
  • 10 Legal issues
  • 11 History: Development of the notion of "algorithm"
    • 11.1 Ancient Near East
    • 11.2 Discrete and distinguishable symbols
    • 11.3 Manipulation of symbols as "place holders" for numbers: algebra
    • 11.4 Cryptographic algorithms
    • 11.5 Mechanical contrivances with discrete states
    • 11.6 Mathematics during the 19th century up to the mid-20th century
    • 11.7 Emil Post (1936) and Alan Turing (1936–37, 1939)
    • 11.8 J.B. Rosser (1939) and S.C. Kleene (1943)
    • 11.9 History after 1950
  • 12 See also

1 History

The concept of algorithm has existed since antiquity. Arithmetic algorithms, such as a division algorithm, were used by ancient Babylonian mathematicians c. 2500 BC and Egyptian mathematicians c. 1550 BC. Greek mathematicians later used algorithms in 240 BC in the sieve of Eratosthenes for finding prime numbers, and the Euclidean algorithm for finding the greatest common divisor of two numbers. Arabic mathematicians such as al-Kindi in the 9th century used cryptographic algorithms for code-breaking, based on frequency analysis.

The word algorithm is derived from the name of the 9th-century Persian mathematician Muḥammad ibn Mūsā al-Khwārizmī, whose nisba (identifying him as from Khwarazm) was Latinized as Algoritmi (Arabized Persian الخوارزمی c. 780–850). Muḥammad ibn Mūsā al-Khwārizmī was a mathematician, astronomer, geographer, and scholar in the House of Wisdom in Baghdad, whose name means ‘the native of Khwarazm’, a region that was part of Greater Iran and is now in Uzbekistan. About 825, al-Khwarizmi wrote an Arabic language treatise on the Hindu–Arabic numeral system, which was translated into Latin during the 12th century. The manuscript starts with the phrase Dixit Algorizmi (‘Thus spake Al-Khwarizmi’), where “Algorizmi” was the translator’s Latinization of Al-Khwarizmi’s name. Al-Khwarizmi was the most widely read mathematician in Europe in the late Middle Ages, primarily through another of his books, the Algebra. In late medieval Latin, algorismus, English ‘algorism’, the corruption of his name, simply meant the “decimal number system”. In the 15th century, under the influence of the Greek word ἀριθμός (arithmos), ‘number’ (cf. ‘arithmetic’), the Latin word was altered to algorithmus, and the corresponding English term ‘algorithm’ is first attested in the 17th century; the modern sense was introduced in the 19th century.

Indian mathematics was predominantly algorithmic. Algorithms that are representative of the Indian mathematical tradition range from the ancient Śulbasūtrās to the medieval texts of the Kerala School.

In English, the word algorithm was first used in about 1230 and then by Chaucer in 1391. English adopted the French term, but it was not until the late 19th century that “algorithm” took on the meaning that it has in modern English.

Another early use of the word is from 1240, in a manual titled Carmen de Algorismo composed by Alexandre de Villedieu. It begins with:

Haec algorismus ars praesens dicitur, in qua / Talibus Indorum fruimur bis quinque figuris.

which translates to:

Algorism is the art by which at present we use those Indian figures, which number two times five.

The poem is a few hundred lines long and summarizes the art of calculating with the new styled Indian dice (Tali Indorum), or Hindu numerals.

A partial formalization of the modern concept of algorithm began with attempts to solve the Entscheidungsproblem (decision problem) posed by David Hilbert in 1928. Later formalizations were framed as attempts to define “effective calculability” or “effective method”. Those formalizations included the Gödel–Herbrand–Kleene recursive functions of 1930, 1934 and 1935, Alonzo Church’s lambda calculus of 1936, Emil Post’s Formulation 1 of 1936, and Alan Turing’s Turing machines of 1936–37 and 1939.

2 Informal definition

For a detailed presentation of the various points of view on the definition of “algorithm”, see Algorithm characterizations.

An informal definition could be “a set of rules that precisely defines a sequence of operations”, which would include all computer programs (including programs that do not perform numeric calculations), and (for example) any prescribed bureaucratic procedure or cook-book recipe.

In general, a program is only an algorithm if it stops eventually—even though infinite loops may sometimes prove desirable.

A prototypical example of an algorithm is the Euclidean algorithm, which is used to determine the maximum common divisor of two integers; an example (there are others) is described by the flowchart above and as an example in a later section.

Boolos, Jeffrey & 1974, 1999 offer an informal meaning of the word “algorithm” in the following quotation:

No human being can write fast enough, or long enough, or small enough† ( †“smaller and smaller without limit … you’d be trying to write on molecules, on atoms, on electrons”) to list all members of an enumerably infinite set by writing out their names, one after another, in some notation. But humans can do something equally useful, in the case of certain enumerably infinite sets: They can give explicit instructions for determining the n n nth member of the set, for arbitrary finite n. Such instructions are to be given quite explicitly, in a form in which they could be followed by a computing machine, or by a human who is capable of carrying out only very elementary operations on symbols.

An “enumerably infinite set” is one whose elements can be put into one-to-one correspondence with the integers. Thus Boolos and Jeffrey are saying that an algorithm implies instructions for a process that “creates” output integers from an arbitrary “input” integer or integers that, in theory, can be arbitrarily large. For example, an algorithm can be an algebraic equation such as y = m + n (i.e., two arbitrary “input variables” m and n that produce an output y), but various authors’ attempts to define the notion indicate that the word implies much more than this, something on the order of (for the addition example):

Precise instructions (in a language understood by “the computer”) for a fast, efficient, “good” process that specifies the “moves” of “the computer” (machine or human, equipped with the necessary internally contained information and capabilities) to find, decode, and then process arbitrary input integers/symbols m and n, symbols + and = … and “effectively” produce, in a “reasonable” time, output-integer y at a specified place and in a specified format.

The concept of algorithm is also used to define the notion of decidability—a notion that is central for explaining how formal systems come into being starting from a small set of axioms and rules. In logic, the time that an algorithm requires to complete cannot be measured, as it is not apparently related to the customary physical dimension. From such uncertainties, that characterize ongoing work, stems the unavailability of a definition of algorithm that suits both concrete (in some sense) and abstract usage of the term.

Most algorithms are intended to be implemented as computer programs. However, algorithms are also implemented by other means, such as in a biological neural network (for example, the human brain implementing arithmetic or an insect looking for food), in an electrical circuit, or in a mechanical device.

3 Formalization

Algorithms are essential to the way computers process data. Many computer programs contain algorithms that detail the specific instructions a computer should perform—in a specific order—to carry out a specified task, such as calculating employees’ paychecks or printing students’ report cards. Thus, an algorithm can be considered to be any sequence of operations that can be simulated by a Turing-complete system. Authors who assert this thesis include Minsky (1967), Savage (1987), and Gurevich (2000):

Minsky: “But we will also maintain, with Turing … that any procedure which could “naturally” be called effective, can, in fact, be realized by a (simple) machine. Although this may seem extreme, the arguments … in its favor are hard to refute”. Gurevich: “… Turing’s informal argument in favor of his thesis justifies a stronger thesis: every algorithm can be simulated by a Turing machine … according to Savage [1987], an algorithm is a computational process defined by a Turing machine”.

Turing machines can define computational processes that do not terminate. The informal definitions of algorithms generally require that the algorithm always terminates. This requirement renders the task of deciding whether a formal procedure is an algorithm impossible in the general case—due to a major theorem of computability theory known as the halting problem.

Typically, when an algorithm is associated with processing information, data can be read from an input source, written to an output device and stored for further processing. Stored data are regarded as part of the internal state of the entity performing the algorithm. In practice, the state is stored in one or more data structures.

For some of these computational processes, the algorithm must be rigorously defined: and specified in the way it applies in all possible circumstances that could arise. This means that any conditional steps must be systematically dealt with, case by case; the criteria for each case must be clear (and computable).

Because an algorithm is a precise list of precise steps, the order of computation is always crucial to the functioning of the algorithm. Instructions are usually assumed to be listed explicitly, and are described as starting “from the top” and going “down to the bottom”—an idea that is described more formally by flow of control.

So far, the discussion on the formalization of an algorithm has assumed the premises of imperative programming. This is the most common conception—one which attempts to describe a task in discrete, “mechanical” means. Unique to this conception of formalized algorithms is the assignment operation, which sets the value of a variable. It derives from the intuition of “memory” as a scratchpad. An example of such an assignment can be found below.

For some alternate conceptions of what constitutes an algorithm, see functional programming and logic programming.

4 Expressing algorithms

Algorithms can be expressed in many kinds of notation, including natural languages, pseudocode, flowcharts, drakon-charts, programming languages or control tables (processed by interpreters). Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms. Pseudocode, flowcharts, drakon-charts and control tables are structured ways to express algorithms that avoid many of the ambiguities common in the statements based on natural language. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but are also often used as a way to define or document algorithms.

There is a wide variety of representations possible and one can express a given Turing machine program as a sequence of machine tables (see finite-state machine, state transition table and control table for more), as flowcharts and drakon-charts (see state diagram for more), or as a form of rudimentary machine code or assembly code called “sets of quadruples” (see Turing machine for more).

Representations of algorithms can be classed into three accepted levels of Turing machine description, as follows:

1 High-level description

“…prose to describe an algorithm, ignoring the implementation details. At this level, we do not need to mention how the machine manages its tape or head.”

2 Implementation description

“…prose used to define the way the Turing machine uses its head and the way that it stores data on its tape. At this level, we do not give details of states or transition function.”

3 Formal description

Most detailed, “lowest level”, gives the Turing machine’s “state table”.

For an example of the simple algorithm “Add m+n” described in all three levels, see Examples.

5 Design

See also: Algorithm § By design paradigm

Algorithm design refers to a method or a mathematical process for problem-solving and engineering algorithms. The design of algorithms is part of many solution theories, such as divide-and-conquer or dynamic programming within operation research. Techniques for designing and implementing algorithm designs are also called algorithm design patterns, with examples including the template method pattern and the decorator pattern.

One of the most important aspects of algorithm design is resource (run-time, memory usage) efficiency; the big O notation is used to describe e.g. an algorithm’s run-time growth as the size of its input increases.

Typical steps in the development of algorithms:

  1. Problem definition
  2. Development of a model
  3. Specification of the algorithm
  4. Designing an algorithm
  5. Checking the correctness of the algorithm
  6. Analysis of algorithm
  7. Implementation of algorithm
  8. Program testing
  9. Documentation preparation

6 Computer algorithms

7 Examples

7.1 Algorithm example

7.2 Euclid’s algorithm

7.2.1 Computer language for Euclid’s algorithm

7.2.2 An inelegant program for Euclid’s algorithm

7.2.3 An elegant program for Euclid’s algorithm

7.3 Testing the Euclid algorithms

7.4 Measuring and improving the Euclid algorithms

8 Algorithmic analysis

8.1 Formal versus empirical

8.2 Execution efficiency

9 Classification

9.1 By implementation

9.2 By design paradigm

9.3 Optimization problems

9.4 By field of study

9.5 By complexity

9.6 Continuous algorithms

10 Legal issues

11 History: Development of the notion of “algorithm”

11.1 Ancient Near East

11.2 Discrete and distinguishable symbols

11.3 Manipulation of symbols as “place holders” for numbers: algebra

11.4 Cryptographic algorithms

11.5 Mechanical contrivances with discrete states

11.6 Mathematics during the 19th century up to the mid-20th century

11.7 Emil Post (1936) and Alan Turing (1936–37, 1939)

11.8 J.B. Rosser (1939) and S.C. Kleene (1943)

11.9 History after 1950

12 See also

这篇关于@TODO的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/659998

相关文章

树莓派3B驱动ST7735(内核)(TODO)

(TODO) https://www.youtube.com/watch?v=dj0WrkpPRho 要在树莓派 3B 上配置支持 ST7735S 显示屏,并在启动过程中将信息输出到这个显示屏,同时允许通过显示屏进行 shell 交互,需要进行以下步骤: ### 1. **安装必要的工具和库** 在配置和编译内核之前,需要确保系统安装了必要的工具和库: ```bash sudo ap

让自家的智能语音助手实现todo任务的添加

我家的树莓派在成为了“智能语音助手”后,经过rasa学习训练,已经可以帮忙查日期/时间,查天气预报,进行一些简单的闲聊。但是,我希望它的功能还可以再强大些,比如说,可以帮我记录todo任务。为了实现这一目标,又花了一周时间,终于在今天实现了这个功能。 要实现这个功能,说白了,就是定义一个todo class,然后通过rasa 的自定义actions来调用这个class,从而实现todo task

Vue(八) localStorage、组件的自定义事件、Todo案例修改

文章目录 一、浏览器本地存储1. 相关API2. Todo案例中的应用 二、组件的自定义事件1. 回顾props传值方式2. 绑定自定义事件(1)方式一:v-on或@(2)方式二: ref 3. 解绑自定义事件4. 注意点总结 三、Todo案例采用自定义事件 一、浏览器本地存储 1. 相关API 存储内容大小一般支持5MB左右(不同浏览器可能还不一样) 浏览器端通过 Win

Vue53-Todo-list案例

一、需求: 二、组件的划分:按照功能划分 组件起名,不要和html内置元素重名! Vue鼓励组件名用多个单词。 三、组件化编码流程  3-1、实现静态组件  将各个组件的基本框架写好,并在App.vue文件中进行引入和注册。 将已有的html元素和css样式,都复制到App.vue文件中,并一个个拆分到对应的组件。 3-2、展示动态数据

在Eclipse中用TODO标签管理任务

在Eclipse中用TODO标签管理任务 Elipse为Java项目的时候,有一个很人性化的“任务管理”功能,利用这个功能可以方便地将项目中一些需要处理的任务记录下来。先来看看“任务管理”是怎么使用的吧。 下面这个类在Class和name 属性的comment中分别加入了一段FIXME 和TODO标签,在FIXME和TODO标签的候命 还跟上了一段文字来说明需要任务的内容。 /**

Mybatis报错sql injection violation, syntax error: TODO :IDENTIFIER

今天被这个报错搞了一下午 <select id="getMmZxZffs" resultType="cn.vetech.asms.pay.service.freepwdpay.vo.ZxZffsQueryVO" parameterType="cn.vetech.asms.pay.service.freepwdpay.dto.ZxZffsQueryDTO">select t.A skFs,t.

【Godot4.2】自定义Todo清单类 - myTodoList

概述 在写myList类的时候,就想到可以写一个类似的Todo清单类。 基础思路 本质还是在内部维护一个数组,在其基础上进行增删改查操作的封装为了方便存储数据,编写一个自定义内置类TodoItem,内部数组就变成了Array[TodoItem]类型的类型化数组。在这个数组基础上编写各种方法。 基于本文所写的这个类实际上已经可以写简单的清单应用了。当然为了能用于打印输出,所以我也设定了以纯字

USB UVC 2-- libuvc(TODO)

书接上回:USB UVC 1-- 基础-CSDN博客 (TODO)