博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
常见排序算法_解释的算法-它们是什么以及常见的排序算法
阅读量:2518 次
发布时间:2019-05-11

本文共 3081 字,大约阅读时间需要 10 分钟。

常见排序算法

In its most basic form, an algorithm is a set of detailed step-by-step instructions to complete a task. For example, an algorithm to make coffee in a french press would be:

在最基本的形式中,算法是一组完成任务的详细分步说明。 例如,在法国媒体中制作咖啡的算法为:

  1. Pour water into the kettle, close the lid, and turn it on.

    将水倒入水壶中,合上盖子,然后打开。
  2. Take the lid off the french press and pour in 17 grams of ground coffee.

    从法国压机上取下盖子,倒入17克咖啡粉。
  3. When the water in the kettle is boiling, pour 290 grams of hot water into the french press.

    当水壶中的水沸腾时,将290克热水倒入法国压榨机中。
  4. Put the lid of the french press back on with the plunger up.

    向上推柱塞,重新盖上法式压力机的盖子。
  5. Wait 4 minutes.

    等待4分钟。
  6. Gently press the plunger down until it reaches the bottom.

    轻轻向下按下柱塞,直至到达底部。
  7. Pour coffee into a mug.

    将咖啡倒入杯子。

In computer science, common algorithms have names like "Quicksort" and "Bogosort". Algorithms are often grouped into different categories like search, sorting, and compression algorithms. Further, algorithms can be described by the approach it takes to complete a task, such as recursive, backtracking, divide and conquer, greedy, and brute force.

在计算机科学中,常用算法的名称如“ Quicksort”和“ Bogosort”。 算法通常分为不同的类别,例如搜索,排序和压缩算法。 此外,可以通过完成任务所需的方法来描述算法,例如递归,回溯,分而治之,贪婪和蛮力。

Algorithms are often paired with data structures, though they are fundamentally different. Data Structures are methods of storing data so that an algorithm can perform operations on it easily.

尽管算法本质上有所不同,但它们通常与数据结构配对。 数据结构是存储数据的方法,以便算法可以轻松地对其执行操作。

Some common examples of data structures are arrays, stacks, queues, linked lists, trees, graphs, hash tables, and heaps.

数据结构的一些常见示例是数组,堆栈,队列,链表,树,图,哈希表和堆。

效率 (Efficiency)

Algorithms are often judged and compared based on their efficiency and the resources they require. One of the most common ways to evaluate an algorithm is to look at its time complexity through a method called .

通常根据算法的效率和所需的资源来对其进行判断和比较。 评估算法的最常见方法之一是通过称为的方法查看其时间复杂度。

Big O notation is a way to describe the speed or complexity of an algorithm, and shows the worst case number of operations for a given input size. It's important to understand the possible run time for different algorithms, especially when working with large or growing data sets. Big O notation makes it easier to choose the right algorithm for each task.

大O表示法是描述算法速度或复杂度的一种方式,并显示了给定输入大小时最坏情况下的运算次数。 重要的是要了解不同算法的可能运行时间,尤其是在处理大型或不断增长的数据集时。 大O表示法使您更轻松地为每个任务选择正确的算法。

排序算法 (Sorting Algorithms)

Sorting algorithms come in various flavors depending on your necessity. Some, very common and widely used are:

排序算法根据您的需要而有不同的风格。 一些非常普遍和广泛使用的是:

快速排序 (Quick Sort)

No sorting discussion is complete without mentioning .

没有提及就没有完整的排序讨论。

合并排序 (Merge Sort)

The algorithm relies on splitting and sorting smaller arrays before merging them into one sorted array.

算法依赖于在将较小的数组合并为一个排序的数组之前对它们进行拆分和排序。

freeCodeCamp’s curriculum heavily emphasizes creating algorithms. This is because learning algorithms is a good way to practice programming skills. Interviewers most commonly test candidates on algorithms during developer job interviews.

freeCodeCamp的课程非常强调创建算法。 这是因为学习算法是练习编程技能的好方法。 面试官最常在开发人员工作面试中测试算法候选人。

翻译自:

常见排序算法

转载地址:http://cmrwd.baihongyu.com/

你可能感兴趣的文章
生产者消费者模型
查看>>
apiCloud 双击事件
查看>>
C#开发微信门户及应用(6)--微信门户菜单的管理操作
查看>>
查看变更(git diff)
查看>>
c++实现单向链表的一些操作
查看>>
Vim中无法用Alt键来映射
查看>>
ubuntu硬件配置查看命令
查看>>
第十二周作业
查看>>
DBSCAN算法的Java,C++,Python实现
查看>>
设置JPA的Query返回Map对象
查看>>
史上最简单MySQL教程详解(进阶篇)之存储过程(二)
查看>>
stack
查看>>
js 压缩
查看>>
oracle数据库----笔记1---PL/SQL基础5---子程序
查看>>
OpenCV学习笔记(二)——OpenCV环境变量配置
查看>>
二叉树遍历(flist)(已知中序和按层遍历,求先序 )
查看>>
自然语言处理第一讲:简介和概述
查看>>
儿童摄影欧美浓郁温暖效果步骤
查看>>
CF 910 C. Minimum Sum
查看>>
jquey :eq(1)
查看>>