バブルソート( JSの例)
4154 ワード
Note: This is not a "professionally written" post. This is a post sharing personal notes I wrote down while preparing for FAANG interviews.
See all of my Google, Amazon, & Facebook interview study notes
バブルソート概要
バブルソートノート
バブルソートは、時折沈没ソートと呼ばれる、単純に並べ替えアルゴリズムは、繰り返しリストを介して、隣接する要素を比較し、スワップをしている場合は、間違った順序にある場合.リストをソートするまでリストを通過します.
バブルソート
const BubbleSort = (items = []) => {
for (let i = 0; i < items.length; i++)
{
for (let j = 0; j < items.length; j++)
{
if (items[j] > items[j + 1])
{
let temporary = items[j]
items[j] = items[j + 1]
items[j + 1] = temporary
}
}
}
return items
}
module.exports = BubbleSort
FAANG Study Resource: Cracking the Coding Interview
(Google Recommended)
My FAANG interview study notes
Bubble Sort Github
Clean Code
Reference
この問題について(バブルソート( JSの例)), 我々は、より多くの情報をここで見つけました https://dev.to/cleancodestudio/bubble-sort-js-example-26fbテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol