Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

Sorting

From Wikibooks, open books for an open world
<A Level Computer Science Programming Guide |Algorithms


Bubble Sort

[edit |edit source]
Regular Bubble Sort
LanguageGeneral Usage
Pseudocode
n ← MaxIndex - 1FOR i ← 1 TO n    FOR j ← 1 TO nIF MyList[j] > MyList[j + 1]THENTemp ← MyList[j]MyList[j] ← MyList[j + 1]MyList[j + 1] ← TempENDIFENDFORn ← n - 1   // this means the next time round the inner loop, we don't        // look at the values already in the correct positions.ENDFOR
VB.NET

Insertion Sort

[edit |edit source]
LanguageGeneral Usage
Pseudocode
FOR Pointer ← 2 TO NumberOfitemsItemToBeInserted ← List[Pointer]CurrentItem ← Pointer - 1 // pointer to last item in sorted part of listWHILE (List[CurrentItem] > ItemToBeInserted) AND (CurrentItem > 0)List[CurrentItem + 1] ← List[CurrentItem] // move current item downCurrentItem ← CurrentItem - 1 // look at the item aboveEND WHILEList[CurrentItem + 1] ← ItemToBeInserted // insert itemENDFOR
VB.NET
Retrieved from "https://en.wikibooks.org/w/index.php?title=A_Level_Computer_Science_Programming_Guide/Algorithms/Sorting&oldid=3800602"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp