Definitionپێناسە
A simple that walks through a list comparing neighbours and swapping every pair that is in the wrong order. After each pass the largest remaining value has "bubbled" to the end, so n values need at most n − 1 passes.
سادەی کە بە دەڕوات، هەر دوو دراوسێیەک بەراورد دەکات و هەر جووتێک بە هەڵە ڕیز بووبێت ئاڵوگۆڕیان پێ دەکات. دوای هەر جارێک گەورەترین لەوانەی ماون وەک بڵق دەگاتە کۆتایی، بۆیە n لانیزۆر n − 1 جاری پێویستە.
Exampleنموونە
[4, -2, 9] → [-2, 4, 9] after the first pass: 4 and −2 swap, 4 and 9 stay.
[4, -2, 9] دوای جاری یەکەم دەبێتە [-2, 4, 9]: 4 و −2 ئاڵوگۆڕ دەکەن، 4 و 9 وەک خۆیان دەمێننەوە.
values = [4, -2, 9]
for j in range(len(values) - 1):
if values[j] > values[j + 1]:
values[j], values[j + 1] = values[j + 1], values[j]
print(values) # [-2, 4, 9]Other Kurdish renderings in useوەرگێڕانە کوردییەکانی تر
ڕیزکردنە بڵقییەکە، ڕیزکردنێکی بڵقی، ڕیزکردنی بڵقیی
Note on the Kurdish termتێبینی دەربارەی زاراوە کوردییەکە
Built like the proposed selection-sort «ڕیزکردن بە هەڵبژاردن» (FOPW8) on the registry's sorting = ڕیزکردن; «بڵقی» (of bubbles) translates the image of the name, as Arabic «الترتيب الفقاعي» does. Proposed by the py-sorting-algorithms writer (PYDW2).
Related termsزاراوە پەیوەندیدارەکان
Videosڤیدیۆکان
Bubble sort step by step: compare neighbours, swap them when they are in the wrong order, then the same in Python code.
هەنگاو بە هەنگاو: دوو دراوسێ بەراورد بکە و ئەگەر ڕیزبەندییان هەڵە بوو جێیان بگۆڕە؛ پاشان هەمان کار بە کۆدی .