




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
「一入Java深似讲师信•劝退师,ApacheCloud••「一入Java深似讲师信•劝退师,ApacheCloud••••主要议•实•二分搜索算•Java二分搜索算法主要议•实•二分搜索算•Java二分搜索算法实•课程总•基本介Analgorithmthatputselementsofalistinacertainorder.Themostfrequentlyusedordersarenumericalorderandlexicographicalorder.基本介Analgorithmthatputselementsofalistinacertainorder.Themostfrequentlyusedordersarenumericalorderandlexicographicalorder.Efficientsortingisimportantforoptimizingtheefficiencyofotheralgorithms(suchassearchandmergealgorithms)whichrequireinputdatatobeinsortedlists.Sortingisalsooftenusefulforcanonicalizingdataandforproducinghuman-readableoutput.Moreformally,theoutputofanysortingalgorithmmustsatisfytwo•Theoutputisinnondecreasingorder(eachelementisnosmallerthanthepreviouselementaccordingtothedesiredtotalorder);•Theoutputisapermutation(areordering,yetretainingalloftheoriginalelements)ofthe•分••••稳定性:当相同的健存在时,经过排序后,其值也保持相对的顺序(不发生变化••分••••稳定性:当相同的健存在时,经过排序后,其值也保持相对的顺序(不发生变化••分••分••计算复杂度计算复杂度•Theamountofresourcesrequiredforrunningit.Thecomputationalcomplexityofaproblemistheminimumofthecomplexitiesofallpossiblealgorithmsforthisproblem(includingtheunknownalgorithms).Astheamountofneededresourcesvarieswiththeinput,thecomplexityisgenerallyexpressedasafunctionn→f(n),wherenisthesizeoftheinput,andf(n)iseithertheworst-casecomplexity,thatisthemaximumoftheamountofresourcesthatareneededforallinputsofsizen,ortheaverage-casecomplexity,thatisaverageoftheamountofresourcesoverallinputofsizen.计算复杂度计算复杂度•Whenthenatureoftheresourcesisnotexplicitlygiven,thisisusuallythetimeneededforrunningthealgorithm,andonetalksoftimecomplexity.However,thisdependsonthecomputerthatisused,andthetimeisgenerallyexpressedasthenumberofneededelementaryoperations,whicharesupposedtotakeaconstanttimeonagivencomputer,andtochangebyaconstantfactorwhenonechangesofcomputer.Otherwise,theresourcethatisconsideredisoftenthesizeofthememorythatisneeded,andonetalksofspacecomplexity.时间复杂度(时间复杂度(Time•Theamountoftimeittakestorunanalgorithm.Timecomplexityiscommonlyestimatedbycountingthenumberofelementaryoperationsperformedbythealgorithm,supposingthateachelementaryoperationtakesafixedamountoftimetoperform.Thus,theamountoftimetakenandthenumberofelementaryoperationsperformedbythealgorithmaretakentodifferbyatmostaconstantfactor.时间复杂度(时间复杂度(Time•Sinceanalgorithm'srunningtimemayvaryamongdifferentinputsofthesamesize,onecommonlyconsiderstheworst-casetimecomplexity,whichisthemaximumamountoftimerequiredforinputsofagivensize.Lesscommon,andusuallyspecifiedexplicitly,istheaverage-casecomplexity,whichistheaverageofthetimetakenoninputsofagivensize(thismakessensebecausethereareonlyafinitenumberofpossibleinputsofagivensize).Inbothcases,thetimecomplexityisgenerallyexpressedasafunctionofthesizeoftheinput.Sincethisfunctionisgenerallydifficulttocomputeexactly,andtherunningtimeforsmallinputsisusuallynotconsequential,onecommonlyfocusesonthebehaviorofthecomplexitywhentheinputsizeincreases—thatis,theasymptoticbehaviorofthe时间复杂度(Time•表达式:BigO•常量时间:T(n)O(1)(数组随机访问•线性时间:T(n)=O(n)(在未排序数组中找寻最值•时间复杂度(Time•表达式:BigO•常量时间:T(n)O(1)(数组随机访问•线性时间:T(n)=O(n)(在未排序数组中找寻最值•对数时间:T(n)=O(logn)(二进制搜索•指数时间:T(n)=O(n^c)(冒泡排序、插入排序•BigO••无限渐进•无限小渐进BigO••无限渐进•无限小渐进•稳定性稳定性•Stablesortalgorithmssortrepeatedelementsinthesameorderthattheyappearintheinput.Whensortingsomekindsofdata,onlypartofthedataisexaminedwhendeterminingthesortorder.Forexample,inthecardsortingexampletotheright,thecardsarebeingsortedbytheirrank,andtheirsuitisbeingignored.Thisallowsthepossibilityofmultipledifferentcorrectlysortedversionsoftheoriginallist.Stablesortingalgorithmschooseoneofthese,accordingtothefollowingrule:iftwoitemscompareasequal,likethetwo5cards,thentheirrelativeorderwillbepreserved,sothatifonecamebeforetheotherintheinput,itwillalsocomebeforetheotherintheoutput.稳定性••稳定性••稳定性••稳定性••比较排•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•时间复杂度:最佳O(n)、平均O(n^2)冒泡排序(Bubble•时间复杂度:最佳O(n)、平均O(n^2)、最坏••插入排序(Insertion•时间复杂度:最佳O(n)、平均O(n^2)插入排序(Insertion•时间复杂度:最佳O(n)、平均O(n^2)、最坏••快速排序(Quick•时间复杂度:最佳O(nlogn)、平均O(nlogn)、最坏••获取pivot(轴•分区快速排序(Quick•时间复杂度:最佳O(nlogn)、平均O(nlogn)、最坏••获取pivot(轴•分区•递归•快速排序(Quick快速排序(Quick••合并排序(Merge•时间复杂度:最佳O(nlogn)、平均O(nlogn)、最坏••分块合并排序(Merge•时间复杂度:最佳O(nlogn)、平均O(nlogn)、最坏••分块•递归合并•合并排序(Merge合并排序(Merge••Tim排序•时间复杂度:最佳O(n)、平均O(nlogn)、最坏Tim排序•时间复杂度:最佳O(n)、平均O(nlogn)、最坏••实实集合框实内建实•冒泡排序•插入排序(7时•快速排序•合并排序Sort):java.util.Arrays#mergeSort集合框实内建实•冒泡排序•插入排序(7时•快速排序•合并排序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等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO/IEC 15421:2010 FR Information technology - Automatic identification and data capture techniques - Bar code master test specifications
- 【正版授权】 ISO/IEC 8183:2023 FR Information technology - Artificial intelligence - Data life cycle framework
- 2025至2030中国白色家电行业市场运行分析及竞争格局与投资方向报告
- 2025至2030中国男士商务正装行业深度研究及发展前景投资评估分析
- 2025至2030中国用于食品和饮料的金属罐行业产业运行态势及投资规划深度研究报告
- 2025至2030中国玻璃门行业深度研究及发展前景投资评估分析
- 2025至2030中国玫瑰花露行业供需分析及发展前景报告
- 2025至2030中国物理治疗软件行业市场深度研究及发展前景投资可行性分析报告
- 商业培训中激励措施的心理机制研究
- 商业环境中残疾人餐具使用的培训与指导
- 2022年一级造价工程师考试《建设工程技术与计量(土木建筑工程)》真题及解析
- 专利基础知识教学课件
- 2015海湾消防JB-QB-GST200 火灾报警控制器(联动型)安装使用说明书
- 中国各省区地图、基本资料
- 2025年上半年中国长江三峡集团限公司“脱贫家庭毕业生”招聘(173人)易考易错模拟试题(共500题)试卷后附参考答案
- 关于办公室安全的培训
- 2025年高考物理复习之小题狂练600题(实验题):测量电压表或电流的内阻(10题)
- 2024年工厂车间主管年终总结
- 血管导管相关感染预防与控制指南课件
- 中建全套消防专项施工方案
- 出国境保密培训
评论
0/150
提交评论