常见排序算法_解释的算法-它们是什么以及常见的排序算法
常見排序算法
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:
在最基本的形式中,算法是一組完成任務(wù)的詳細(xì)分步說明。 例如,在法國媒體中制作咖啡的算法為:
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.
在計算機科學(xué)中,常用算法的名稱如“ Quicksort”和“ Bogosort”。 算法通常分為不同的類別,例如搜索,排序和壓縮算法。 此外,可以通過完成任務(wù)所需的方法來描述算法,例如遞歸,回溯,分而治之,貪婪和蠻力。
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.
盡管算法本質(zhì)上有所不同,但它們通常與數(shù)據(jù)結(jié)構(gòu)配對。 數(shù)據(jù)結(jié)構(gòu)是存儲數(shù)據(jù)的方法,以便算法可以輕松地對其執(zhí)行操作。
Some common examples of data structures are arrays, stacks, queues, linked lists, trees, graphs, hash tables, and heaps.
數(shù)據(jù)結(jié)構(gòu)的一些常見示例是數(shù)組,堆棧,隊列,鏈表,樹,圖,哈希表和堆。
效率 (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.
通常根據(jù)算法的效率和所需的資源來對其進行判斷和比較。 評估算法的最常見方法之一是通過稱為Big O表示法的方法查看其時間復(fù)雜度。
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表示法是描述算法速度或復(fù)雜度的一種方式,并顯示了給定輸入大小時最壞情況下的運算次數(shù)。 重要的是要了解不同算法的可能運行時間,尤其是在處理大型或不斷增長的數(shù)據(jù)集時。 大O表示法使您更輕松地為每個任務(wù)選擇正確的算法。
排序算法 (Sorting Algorithms)
Sorting algorithms come in various flavors depending on your necessity. Some, very common and widely used are:
排序算法根據(jù)您的需要而有不同的風(fēng)格。 一些非常普遍和廣泛使用的是:
快速排序 (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.
合并排序算法依賴于在將較小的數(shù)組合并為一個排序的數(shù)組之前對它們進行拆分和排序。
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的課程非常強調(diào)創(chuàng)建算法。 這是因為學(xué)習(xí)算法是練習(xí)編程技能的好方法。 面試官最常在開發(fā)人員工作面試中測試算法候選人。
翻譯自: https://www.freecodecamp.org/news/algorithms-explained-what-they-are-and-common-sorting-algorithms/
常見排序算法
總結(jié)
以上是生活随笔為你收集整理的常见排序算法_解释的算法-它们是什么以及常见的排序算法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 女人梦到别人在卖猪肉是什么预兆
- 下一篇: 梦到一只狗一只猫是什么意思