Bubble sort - Free Pascal wiki
文章推薦指數: 80 %
unit UBubbleSort; interface type // data type TItemBubbleSort=integer; procedure BubbleSort( var a: array of TItemBubbleSort ) ... BubblesortFromFreePascalwikiJumptonavigationJumptosearch │ English (en)│ suomi (fi)│ français (fr)│ Bubblesortisasimplesortingalgorithm. Contents 1Characteristics 2UnitUBubbleSort 3Exampleofusage 4Seealso Characteristics Veryslow Suitableonlyforsmallquantitiessorting Fastonlywhenthearrayisnearlysorted UnitUBubbleSort unitUBubbleSort; interface type //datatype TItemBubbleSort=integer; procedureBubbleSort(vara:arrayofTItemBubbleSort); implementation procedureswap(vara,b:TItemBubbleSort); var temp:TItemBubbleSort; begin temp:=a; a:=b; b:=temp; end; procedureBubbleSort(vara:arrayofTItemBubbleSort); var n,newn,i:integer; begin n:=high(a); repeat newn:=0; fori:=1tondo begin ifa[i-1]>a[i]then begin swap(a[i-1],a[i]); newn:=i; end; end; n:=newn; untiln=0; end; end. Exampleofusage uses UBubbleSort ... var a:array[0..100]ofinteger; begin ... BubbleSort(a); ... Seealso COMP1Revise&Learn :BubbleSort Retrievedfrom"http://wiki.freepascal.org/index.php?title=Bubble_sort&oldid=142736" Category:SortNavigationmenuPageactionsPageDiscussionViewsourceHistoryPageactionsPageDiscussionMoreToolsInotherlanguagesPersonaltoolsCreateaccountLoginNavigationMainPageDocumentationFAQDownloadsGlossaryIndexRecentchangesRandompageHelpToolsWhatlinkshereRelatedchangesSpecialpagesPrintableversionPermanentlinkPageinformationSearch Thispagewaslasteditedon27January2021,at21:47.Contentisavailableunderunlessotherwisenoted.PrivacypolicyAboutFreePascalwikiDisclaimers
延伸文章資訊
- 1冒泡排序- 维基百科,自由的百科全书
冒泡排序(英語:Bubble Sort)又稱為泡式排序,是一種簡單的排序算法。它重複地走訪過要排序的數列,一次比較兩個元素,如果它們的順序錯誤就把它們交換過來。
- 2Bubble sort - Free Pascal wiki
unit UBubbleSort; interface type // data type TItemBubbleSort=integer; procedure BubbleSort( var ...
- 3What Is Bubble Sort? Bubble Sort Definition, Advantages, & FAQ
- 4What is Bubble Sort? | Definition and Overview - ProductPlan
- 5What is Bubble Sort Algorithm? Time Complexity & Pseudocode