一入深似海系列課程-二期四節(jié)集合框架算法運(yùn)用_第1頁(yè)
一入深似海系列課程-二期四節(jié)集合框架算法運(yùn)用_第2頁(yè)
一入深似海系列課程-二期四節(jié)集合框架算法運(yùn)用_第3頁(yè)
一入深似海系列課程-二期四節(jié)集合框架算法運(yùn)用_第4頁(yè)
一入深似海系列課程-二期四節(jié)集合框架算法運(yùn)用_第5頁(yè)
已閱讀5頁(yè),還剩29頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

「一入Java深似講師信?勸退師,ApacheCloud??「一入Java深似講師信?勸退師,ApacheCloud????主要議?實(shí)?二分搜索算?Java二分搜索算法主要議?實(shí)?二分搜索算?Java二分搜索算法實(shí)?課程總?基本介Analgorithmthatputselementsofalistinacertainorder.Themostfrequentlyusedordersarenumericalorderandlexicographicalorder.基本介Analgorithmthatputselementsofalistinacertainorder.Themostfrequentlyusedordersarenumericalorderandlexicographicalorder.Efficientsortingisimportantforoptimizingtheefficiencyofotheralgorithms(suchassearchandmergealgorithms)whichrequireinputdatatobeinsortedlists.Sortingisalsooftenusefulforcanonicalizingdataandforproducinghuman-readableoutput.Moreformally,theoutputofanysortingalgorithmmustsatisfytwo?Theoutputisinnondecreasingorder(eachelementisnosmallerthanthepreviouselementaccordingtothedesiredtotalorder);?Theoutputisapermutation(areordering,yetretainingalloftheoriginalelements)ofthe?分????穩(wěn)定性:當(dāng)相同的健存在時(shí),經(jīng)過排序后,其值也保持相對(duì)的順序(不發(fā)生變化??分????穩(wěn)定性:當(dāng)相同的健存在時(shí),經(jīng)過排序后,其值也保持相對(duì)的順序(不發(fā)生變化??分??分??計(jì)算復(fù)雜度計(jì)算復(fù)雜度?Theamountofresourcesrequiredforrunningit.Thecomputationalcomplexityofaproblemistheminimumofthecomplexitiesofallpossiblealgorithmsforthisproblem(includingtheunknownalgorithms).Astheamountofneededresourcesvarieswiththeinput,thecomplexityisgenerallyexpressedasafunctionn→f(n),wherenisthesizeoftheinput,andf(n)iseithertheworst-casecomplexity,thatisthemaximumoftheamountofresourcesthatareneededforallinputsofsizen,ortheaverage-casecomplexity,thatisaverageoftheamountofresourcesoverallinputofsizen.計(jì)算復(fù)雜度計(jì)算復(fù)雜度?Whenthenatureoftheresourcesisnotexplicitlygiven,thisisusuallythetimeneededforrunningthealgorithm,andonetalksoftimecomplexity.However,thisdependsonthecomputerthatisused,andthetimeisgenerallyexpressedasthenumberofneededelementaryoperations,whicharesupposedtotakeaconstanttimeonagivencomputer,andtochangebyaconstantfactorwhenonechangesofcomputer.Otherwise,theresourcethatisconsideredisoftenthesizeofthememorythatisneeded,andonetalksofspacecomplexity.時(shí)間復(fù)雜度(時(shí)間復(fù)雜度(Time?Theamountoftimeittakestorunanalgorithm.Timecomplexityiscommonlyestimatedbycountingthenumberofelementaryoperationsperformedbythealgorithm,supposingthateachelementaryoperationtakesafixedamountoftimetoperform.Thus,theamountoftimetakenandthenumberofelementaryoperationsperformedbythealgorithmaretakentodifferbyatmostaconstantfactor.時(shí)間復(fù)雜度(時(shí)間復(fù)雜度(Time?Sinceanalgorithm'srunningtimemayvaryamongdifferentinputsofthesamesize,onecommonlyconsiderstheworst-casetimecomplexity,whichisthemaximumamountoftimerequiredforinputsofagivensize.Lesscommon,andusuallyspecifiedexplicitly,istheaverage-casecomplexity,whichistheaverageofthetimetakenoninputsofagivensize(thismakessensebecausethereareonlyafinitenumberofpossibleinputsofagivensize).Inbothcases,thetimecomplexityisgenerallyexpressedasafunctionofthesizeoftheinput.Sincethisfunctionisgenerallydifficulttocomputeexactly,andtherunningtimeforsmallinputsisusuallynotconsequential,onecommonlyfocusesonthebehaviorofthecomplexitywhentheinputsizeincreases—thatis,theasymptoticbehaviorofthe時(shí)間復(fù)雜度(Time?表達(dá)式:BigO?常量時(shí)間:T(n)O(1)(數(shù)組隨機(jī)訪問?線性時(shí)間:T(n)=O(n)(在未排序數(shù)組中找尋最值?時(shí)間復(fù)雜度(Time?表達(dá)式:BigO?常量時(shí)間:T(n)O(1)(數(shù)組隨機(jī)訪問?線性時(shí)間:T(n)=O(n)(在未排序數(shù)組中找尋最值?對(duì)數(shù)時(shí)間:T(n)=O(logn)(二進(jìn)制搜索?指數(shù)時(shí)間:T(n)=O(n^c)(冒泡排序、插入排序?BigO??無限漸進(jìn)?無限小漸進(jìn)BigO??無限漸進(jìn)?無限小漸進(jìn)?穩(wěn)定性穩(wěn)定性?Stablesortalgorithmssortrepeatedelementsinthesameorderthattheyappearintheinput.Whensortingsomekindsofdata,onlypartofthedataisexaminedwhendeterminingthesortorder.Forexample,inthecardsortingexampletotheright,thecardsarebeingsortedbytheirrank,andtheirsuitisbeingignored.Thisallowsthepossibilityofmultipledifferentcorrectlysortedversionsoftheoriginallist.Stablesortingalgorithmschooseoneofthese,accordingtothefollowingrule:iftwoitemscompareasequal,likethetwo5cards,thentheirrelativeorderwillbepreserved,sothatifonecamebeforetheotherintheinput,itwillalsocomebeforetheotherintheoutput.穩(wěn)定性??穩(wěn)定性??穩(wěn)定性??穩(wěn)定性??比較排?Acomparisonsortisatypeofsortingalgorithmthatonlyreadsthelistelementsthroughasingleabstractcomparison比較排?Acomparisonsortisatypeofsortingalgorithmthatonlyreadsthelistelementsthroughasingleabstractcomparisonoperation(oftena"lessthanorequalto"operatororathree-waycomparison)thatdetermineswhichoftwoelementsshouldoccurfirstinthefinalsortedlist.Theonlyrequirementisthattheoperatorobeytwoofthepropertiesofatotalifa≤bandb≤cthena≤cforallaandb,eithera≤borb≤a(totalnessor比較排?冒泡排序(BubbleSort):最佳O(n)、平均O(n^2)、最壞?插入排序(InsertionSort):最佳O(n)、平均O(n^2)、最壞?快速排序(QuickSort):最佳O(nlogn)、平均比較排?冒泡排序(BubbleSort):最佳O(n)、平均O(n^2)、最壞?插入排序(InsertionSort):最佳O(n)、平均O(n^2)、最壞?快速排序(QuickSort):最佳O(nlogn)、平均O(nlogn)、最壞?合并排序(MergeSort):最佳O(nlogn)、平均O(nlogn)、最壞?Tim排序(TimSort):最佳O(n)、平均O(nlogn)、最壞?冒泡排序(Bubble?時(shí)間復(fù)雜度:最佳O(n)、平均O(n^2)冒泡排序(Bubble?時(shí)間復(fù)雜度:最佳O(n)、平均O(n^2)、最壞??插入排序(Insertion?時(shí)間復(fù)雜度:最佳O(n)、平均O(n^2)插入排序(Insertion?時(shí)間復(fù)雜度:最佳O(n)、平均O(n^2)、最壞??快速排序(Quick?時(shí)間復(fù)雜度:最佳O(nlogn)、平均O(nlogn)、最壞??獲取pivot(軸?分區(qū)快速排序(Quick?時(shí)間復(fù)雜度:最佳O(nlogn)、平均O(nlogn)、最壞??獲取pivot(軸?分區(qū)?遞歸?快速排序(Quick快速排序(Quick??合并排序(Merge?時(shí)間復(fù)雜度:最佳O(nlogn)、平均O(nlogn)、最壞??分塊合并排序(Merge?時(shí)間復(fù)雜度:最佳O(nlogn)、平均O(nlogn)、最壞??分塊?遞歸合并?合并排序(Merge合并排序(Merge??Tim排序?時(shí)間復(fù)雜度:最佳O(n)、平均O(nlogn)、最壞Tim排序?時(shí)間復(fù)雜度:最佳O(n)、平均O(nlogn)、最壞??實(shí)實(shí)集合框?qū)崈?nèi)建實(shí)?冒泡排序?插入排序(7時(shí)?快速排序?合并排序Sort):java.util.Arrays#mergeSort集合框?qū)崈?nèi)建實(shí)?冒泡排序?插入排序(7時(shí)?快速排序?合并排序Sort):java.util.Arrays#mergeSort之后需要激活?Tim排序?二分搜索(Binary二分搜索(Binary?Alsoknownashalf-intervalsearch,logarithmicsearch,orbinarychop,isasearchalgorithmthatfindsthepositionofatargetvaluewithinasortedarray.Binarysearchcomparesthetargetvaluetothemiddleelementofthearray.Iftheyarenotequal,thehalfinwhichthetargetcannotlieiseliminatedandthesearchcontinuesontheremaininghalf,againtakingthemiddleelementtocomparetothetarget

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論