大二上学习数据结构lec_第1页
大二上学习数据结构lec_第2页
大二上学习数据结构lec_第3页
大二上学习数据结构lec_第4页
大二上学习数据结构lec_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Improve Run GenerationOverlap input,output, and internal CPU work.Reduce the number of runs (equivalently, increase average run length).DISKMEMORYDISKInternal Quick Sort6285111041973Use 6 as the pivot (median of 3).Input first, middle, and last blocks first.In-place partitioning.Input blocks from th

2、e ends toward the middle.Sort left and right groups recursively.Can begin output as soon as left most block is ready.4235161011978Alternative Internal Sort SchemeDISKDISKB1B2B3Partition into 3 buffers.Steady State OperationRead from diskWrite to diskRun generationSynchronization is done when the act

3、ive input buffer gets empty (the active output buffer will be full at this time).DISKMEMORYDISKNew StrategyUse 2 input and 2 output buffers.Rest of memory is used for a min loser tree.Input 1Input 0Output 0Output 1Loser TreeSteady State OperationRead from diskWrite to diskRun generationSynchronizati

4、on is done when the active input buffer gets empty (the active output buffer will be full at this time).4368157326945258438O0O1I0I1InitializeFill From Disk43681573269452584683517InitializeO0O1I0I1Fill From Disk436815732694525846835371629InitializeO0O1I0I1Fill From Disk4368157326945258468353725281649

5、InitializeO0O1I0I1Fill From Disk4368157326945258468353725581649InitializeO0O1I0I1Fill From Disk4368157326945258468353725582649InitializeO0O1I0I1Fill From DiskGenerate Run 11436857326945258468353725582649O0O1I0I1354Fill From DiskFill From TreeGenerate Run 1436857326945258468353725582649O0O1I0I1354Fil

6、l From DiskFill From Tree1335O023Generate Run 143685736945258468353725583649O1I0I1354Fill From DiskFill From Tree15445O023Generate Run 143685736945258468353725583649O1I0I1354Fill From DiskFill From Tree154Interchange Role Of Buffers5O02343685736945258468353725583649O1I0I1Fill From DiskWrite To Disk1

7、544Interchange Role Of Buffers192Fill From Tree5O02343685736945258468353745583649O1I0I1Fill From DiskWrite To Disk1544192Fill From TreeContinue With Run 1O1345O0243685736945258468353745584649I0I1Fill From DiskWrite To Disk151192Fill From TreeContinue With Run 1151O1345O024368573694525846835374558464

8、9I0I1Fill From DiskWrite To Disk151192Fill From TreeContinue With Run 15995791O1345O0243685736945258468353745584649I0I1Fill From DiskWrite To Disk151192Fill From TreeContinue With Run 159572Interchange Role Of Buffers91O1345O04368573694558468353745584649I0I1Fill From DiskWrite To Disk51613Fill From

9、Tree59572Interchange Role Of Buffers91O1345O04368573694558468353745584649I0I1Fill From DiskWrite To Disk51613Fill From Tree59572Continue With Run 12291O1345O04368573694558468353745584649I0I1Fill From DiskWrite To Disk51613Fill From Tree5957Continue With Run 12665291O1345O0436857369455846835374558464

10、9I0I1Fill From DiskWrite To Disk51613Fill From Tree5957Continue With Run 126651195Let k be number of external nodes in loser tree.Run size = k.Sorted input = 1 run.Reverse of sorted input = n/k runs.Average run size is 2k.RUN SIZEMemory capacity = m records.Run size using fill memory, sort, and outp

11、ut run scheme = m.Use loser tree scheme.Assume block size is b records.Need memory for 4 buffers (4b records).Loser tree k = m 4b.Average run size = 2k = 2(m 4b).2k = m when m = 8b.ComparisonAssume b = 100.Comparisonm6001000500010000k200 6004600 96002k4001200920019200Total internal processing time using fill memory, sort, and output run scheme = O(n/m) m log m) = O(n log m).Total internal processing time using lo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论