Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

A Level Computer Science Programming Guide/Algorithms/Sorting

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Bubble Sort +Regular Bubble SortLanguageGeneral UsagePseudocoden ← MaxIndex - 1 FOR i ← 1 TO n FOR j ← 1 TO n IF MyList[j] > MyList[j + 1] THEN Temp ← MyList[j] MyList[j] ← MyList[j + 1] MyList[j + 1] ← Temp ENDIF ENDFOR n ← n - 1 // this means the next time round the inner loop, we don't // look at the values already in the correct positions. ENDFORVB.NET Insertion Sort LanguageGeneral UsagePseudocodeFOR Pointer ← 2 TO NumberOfitems ItemToBeInserted ← List[Pointer] CurrentItem ← Pointer - 1 // pointer to last item in sorted part of list WHILE (List[CurrentItem] > ItemToBeInserted) AND (CurrentItem > 0) List[CurrentItem + 1] ← List[CurrentItem] // move current item down CurrentItem ← CurrentItem - 1 // look at the item above END WHILE List[CurrentItem + 1] ← ItemToBeInserted // insert item ENDFORVB.NET