常見排序算法_解釋的算法-它們是什么以及常見的排序算法

常見排序算法

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/

常見排序算法

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390751.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390751.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390751.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

020-Spring Boot 監控和度量

一、概述 通過配置使用actuator查看監控和度量信息 二、使用 2.1、建立web項目&#xff0c;增加pom <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency> 啟動項目&a…

matplotlib布局_Matplotlib多列,行跨度布局

matplotlib布局For Visualization in Python, Matplotlib library has been the workhorse for quite some time now. It has held its own even after more nimble rivals with easier code interface and capabilities like seaborn, plotly, bokeh etc. have arrived on the…

Hadoop生態系統

大數據架構-Lambda Lambda架構由Storm的作者Nathan Marz提出。旨在設計出一個能滿足實時大數據系統關鍵特性的架構&#xff0c;具有高容錯、低延時和可擴展等特性。Lambda架構整合離線計算和實時計算&#xff0c;融合不可變性&#xff08;Immutability&#xff09;&#xff0c…

javascript之 原生document.querySelector和querySelectorAll方法

querySelector和querySelectorAll是W3C提供的 新的查詢接口&#xff0c;其主要特點如下&#xff1a; 1、querySelector只返回匹配的第一個元素&#xff0c;如果沒有匹配項&#xff0c;返回null。 2、querySelectorAll返回匹配的元素集合&#xff0c;如果沒有匹配項&#xff0c;…

RDBMS數據定時采集到HDFS

[toc] RDBMS數據定時采集到HDFS 前言 其實并不難&#xff0c;就是使用sqoop定時從MySQL中導入到HDFS中&#xff0c;主要是sqoop命令的使用和Linux腳本的操作這些知識。 場景 在我們的場景中&#xff0c;需要每天將數據庫中新增的用戶數據采集到HDFS中&#xff0c;數據庫中有tim…

單詞嵌入_神秘的文本分類:單詞嵌入簡介

單詞嵌入Natural language processing (NLP) is an old science that started in the 1950s. The Georgetown IBM experiment in 1954 was a big step towards a fully automated text translation. More than 60 Russian sentences were translated into English using simple…

使用Hadoop所需要的一些Linux基礎

Linux 概念 Linux 是一個類Unix操作系統&#xff0c;是 Unix 的一種&#xff0c;它 控制整個系統基本服務的核心程序 (kernel) 是由 Linus 帶頭開發出來的&#xff0c;「Linux」這個名稱便是以 「Linus’s unix」來命名的。 Linux泛指一類操作系統&#xff0c;具體的版本有&a…

python多項式回歸_Python從頭開始的多項式回歸

python多項式回歸Polynomial regression in an improved version of linear regression. If you know linear regression, it will be simple for you. If not, I will explain the formulas here in this article. There are other advanced and more efficient machine learn…

《Linux命令行與shell腳本編程大全 第3版》Linux命令行---4

以下為閱讀《Linux命令行與shell腳本編程大全 第3版》的讀書筆記&#xff0c;為了方便記錄&#xff0c;特地與書的內容保持同步&#xff0c;特意做成一節一次隨筆&#xff0c;特記錄如下&#xff1a; 《Linux命令行與shell腳本編程大全 第3版》Linux命令行--- Linux命令行與she…

徹底搞懂 JS 中 this 機制

徹底搞懂 JS 中 this 機制 摘要&#xff1a;本文屬于原創&#xff0c;歡迎轉載&#xff0c;轉載請保留出處&#xff1a;https://github.com/jasonGeng88/blog 目錄 this 是什么this 的四種綁定規則綁定規則的優先級綁定例外擴展&#xff1a;箭頭函數this 是什么 理解this之前&a…

?如何在2分鐘內將GraphQL服務器添加到RESTful Express.js API

You can get a lot done in 2 minutes, like microwaving popcorn, sending a text message, eating a cupcake, and hooking up a GraphQL server.您可以在2分鐘內完成很多工作&#xff0c;例如微波爐爆米花&#xff0c;發送短信&#xff0c; 吃蛋糕以及連接GraphQL服務器 。 …

leetcode 1744. 你能在你最喜歡的那天吃到你最喜歡的糖果嗎?

給你一個下標從 0 開始的正整數數組 candiesCount &#xff0c;其中 candiesCount[i] 表示你擁有的第 i 類糖果的數目。同時給你一個二維數組 queries &#xff0c;其中 queries[i] [favoriteTypei, favoriteDayi, dailyCapi] 。 你按照如下規則進行一場游戲&#xff1a; 你…

回歸分析_回歸

回歸分析Machine learning algorithms are not your regular algorithms that we may be used to because they are often described by a combination of some complex statistics and mathematics. Since it is very important to understand the background of any algorith…

ruby nil_Ruby中的數據類型-True,False和Nil用示例解釋

ruby niltrue, false, and nil are special built-in data types in Ruby. Each of these keywords evaluates to an object that is the sole instance of its respective class.true &#xff0c; false和nil是Ruby中的特殊內置數據類型。 這些關鍵字中的每一個都求值為一個對…

淺嘗flutter中的動畫(淡入淡出)

在移動端開發中&#xff0c;經常會有一些動畫交互&#xff0c;比如淡入淡出,效果如圖&#xff1a; 因為官方封裝好了AnimatedOpacity Widget&#xff0c;開箱即用&#xff0c;所以我們用起來很方便&#xff0c;代碼量很少&#xff0c;做少量配置即可&#xff0c;所以&#xff0…

數據科學還是計算機科學_何時不使用數據科學

數據科學還是計算機科學意見 (Opinion) 目錄 (Table of Contents) Introduction 介紹 Examples 例子 When You Should Use Data Science 什么時候應該使用數據科學 Summary 摘要 介紹 (Introduction) Both Data Science and Machine Learning are useful fields that apply sev…

空間復雜度 用什么符號表示_什么是大O符號解釋:時空復雜性

空間復雜度 用什么符號表示Do you really understand Big O? If so, then this will refresh your understanding before an interview. If not, don’t worry — come and join us for some endeavors in computer science.您真的了解Big O嗎&#xff1f; 如果是這樣&#xf…

leetcode 523. 連續的子數組和

給你一個整數數組 nums 和一個整數 k &#xff0c;編寫一個函數來判斷該數組是否含有同時滿足下述條件的連續子數組&#xff1a; 子數組大小 至少為 2 &#xff0c;且 子數組元素總和為 k 的倍數。 如果存在&#xff0c;返回 true &#xff1b;否則&#xff0c;返回 false 。 …

Docker學習筆記 - Docker Compose

一、概念 Docker Compose 用于定義運行使用多個容器的應用&#xff0c;可以一條命令啟動應用&#xff08;多個容器&#xff09;。 使用Docker Compose 的步驟&#xff1a; 定義容器 Dockerfile定義應用的各個服務 docker-compose.yml啟動應用 docker-compose up二、安裝 Note t…

創建shell腳本

1.寫一個腳本 a) 用touch命令創建一個文件&#xff1a;touch my_script b) 用vim編輯器打開my_script文件&#xff1a;vi my_script c) 用vim編輯器編輯my_script文件,內容如下&#xff1a; #!/bin/bash 告訴shell使用什么程序解釋腳本 #My first script l…