常见排序算法_解释的算法-它们是什么以及常见的排序算法

常见排序算法

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.

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

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 Quick Sort.

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

合并排序 (Merge Sort)

The Merge Sort 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的课程非常强调创建算法。 这是因为学习算法是练习编程技能的好方法。 面试官最常在开发人员工作面试中测试算法候选人。

翻译自: https://www.freecodecamp.org/news/algorithms-explained-what-they-are-and-common-sorting-algorithms/

常见排序算法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值