![數(shù)據(jù)結(jié)構(gòu)教學(xué)課件:chapter8_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-4/28/3583a995-2d9a-41ff-8194-43adeab288dc/3583a995-2d9a-41ff-8194-43adeab288dc1.gif)
![數(shù)據(jù)結(jié)構(gòu)教學(xué)課件:chapter8_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-4/28/3583a995-2d9a-41ff-8194-43adeab288dc/3583a995-2d9a-41ff-8194-43adeab288dc2.gif)
![數(shù)據(jù)結(jié)構(gòu)教學(xué)課件:chapter8_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-4/28/3583a995-2d9a-41ff-8194-43adeab288dc/3583a995-2d9a-41ff-8194-43adeab288dc3.gif)
![數(shù)據(jù)結(jié)構(gòu)教學(xué)課件:chapter8_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-4/28/3583a995-2d9a-41ff-8194-43adeab288dc/3583a995-2d9a-41ff-8194-43adeab288dc4.gif)
![數(shù)據(jù)結(jié)構(gòu)教學(xué)課件:chapter8_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-4/28/3583a995-2d9a-41ff-8194-43adeab288dc/3583a995-2d9a-41ff-8194-43adeab288dc5.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、120:452Primary storage: Main memory (RAM)Secondary Storage: Peripheral devicesDisk drivesTape drives20:453RAM is usually volatile.RAM is about 1/4 million times faster than disk.MediumEarly 1996 Mid 1997 Early 2000RAM$45.007.001.50Disk1Floppy0.500.360.25Tape0.030.010.00120:454Minimize the
2、 number of disk accesses!1. Arrange information so that you get what you want with few disk accesses.2. Arrange information to minimize future disk accesses.An organization for data on disk is often called a file structure.Disk-based space/time tradeoff: Compress information to save processing time
3、by reducing disk accesses.20:45520:456A sector is the basic unit of I/O.Interleaving factor: Physical distance between logically adjacent sectors on a track.20:457Locality of Reference: When record is read from disk, next request is likely to come from near the same place in the file.Cluster: Smalle
4、st unit of file allocation, usually several sectors.Extent: A group of physically contiguous clusters.Internal fragmentation: Wasted space within sector if record size does not match sector size; wasted space within cluster if file size is not a multiple of cluster size.Sector headers: Contains the
5、sector address and an error detection code for the contents of that sector. See P267 Figure 8.5.20:458Seek time: Time for I/O head to reach desired track. Largely determined by distance between I/O head and desired track.Track-to-track time: Minimum time to move from one track to an adjacent track.A
6、verage Seek time: Average time to reach a track for random access.20:459Rotational Delay or Latency: Time for data to rotate under I/O head.One half of a rotation on average.At 7200 rpm, this is 8.3/2 = 4.2ms.Transfer time: Time for data to move under the I/O head.At 7200 rpm: Number of sectors read
7、/Number of sectors per track * 8.3ms.20:451016.8 GB disk on 10 platters = 1.68GB/platter13,085 tracks/platter256 sectors/track512 bytes/sectorTrack-to-track seek time: 2.2 msAverage seek time: 9.5ms8 sector/clusters =4KB, 32 clusters/track.Interleaving factor of 3.5400RPM20:4511Read a 1MB file divid
8、ed into 2048 records of 512 bytes (1 sector) each.Assume all records are on 8 contiguous tracks.First track: 9.5 + 11.1/2 + 3 x 11.1 = 48.4 msRemaining 7 tracks: 2.2 + 11.1/2 + 3 x 11.1 = 41.1 ms.Total: 48.4 + 7 * 41.1 = 335.7ms20:4512Read a 1MB file divided into 2048 records of 512 bytes (1 sector)
9、 each.Assume all file clusters are randomly spread across the disk.256 clusters. Cluster read time is (3 x 8)/256 of a rotation for about 1 ms.256(9.5 + 11.1/2 + (3 x 8)/256) is about 4119.2 ms. 20:4513Read time for one track:9.5 + 11.1/2 + 3 x 11.1 = 48.4ms.Read time for one sector:9.5 + 11.1/2 + (
10、1/256)11.1 = 15.1ms.Read time for one byte:9.5 + 11.1/2 = 15.05 ms.Nearly all disk drives read/write one sector at every I/O access.Also referred to as a page.20:4514The information in a sector is stored in a buffer or cache.If the next I/O access is to the same buffer, then no need to go to disk.Th
11、ere are usually one or more input buffers and one or more output buffers.20:4515A series of buffers used by an application to cache disk data is called a buffer pool.Virtual memory uses a buffer pool to imitate greater RAM memory by actually storing information on disk and “swapping” between disk an
12、d RAM.20:451620:4517Which buffer should be replaced when new data must be read?First-in, First-out: Use the first one on the queue.Least Frequently Used (LFU): Count buffer accesses, reuse the least used.Least Recently used (LRU): Keep buffers on a linked list. When buffer is accessed, bring it to f
13、ront. Reuse the one at end.20:4518class BufferPool / (1) Message Passingpublic: virtual void insert(void* space, int sz, int pos) = 0; virtual void getbytes(void* space, int sz, int pos) = 0;class BufferPool / (2) Buffer Passingpublic: virtual void* getblock(int block) = 0; virtual void dirtyblock(i
14、nt block) = 0; virtual int blocksize() = 0;20:4519Problem: Sorting data sets too large to fit into main memory.Assume data are stored on disk drive.To sort, portions of the data must be brought into main memory, processed, and returned to disk.An external sort should minimize disk accesses.20:4520Se
15、condary memory is divided into equal-sized blocks (512, 1024, etc)A basic I/O operation transfers the contents of one disk block to/from main memory.Under certain circumstances, reading blocks of a file in sequential order is more efficient. Primary goal is to minimize I/O operations.Assume only one
16、 disk drive is available.20:4521Often, records are large, keys are small.Ex: Payroll entries keyed on ID numberApproach 1: Read in entire records, sort them, then write them out again.Approach 2: Read only the key values, store with each key the location on disk of its associated record.After keys a
17、re sorted the records can be read and rewritten in sorted order.20:4522Quicksort requires random access to the entire set of records.Better: Modified Mergesort algorithm.Process n elements in Q(log n) passes.A group of sorted records is called a run.20:4523Split the file into two run files.Read in a
18、 block from each run file.Take first record from each block, output them in sorted order.Take next record from each block, output them to a second file in sorted order.Repeat until finished, alternating between output files. Read new input blocks as needed.Repeat steps 2-5, except this time input fi
19、les have runs of two sorted records that are merged together.Each pass through the files provides larger runs.20:452420:4525How can we reduce the number of Mergesort passes? Not use Mergesort on small runs, read in a block of data and sort it in memory, and then output it as a single sorted run. (Se
20、e example in page 280)In general, external sorting consists of two phases:Break the files into large initial runsMerge the runs together to form a single sorted run file.20:4526General approaches:Read as much of the data of file into memory as possible.Perform an in-memory sort such as Quicksort or
21、Heapsort.Output this group of sorted records as a single run.20:4527A basic I/O operation is read/write a block. Replacement selection sort is a technology of generating a run as larger as possible based on the basic I/O operations.It is a slight variation on Heapsort algorithm.Break available memor
22、y into an array for the heap, an input buffer, and an output buffer.20:4528 1) Fill the array from disk. Set LAST=M-1; 2) Build a min-heap; 3) Repeat until the array is empty: a) Send the record with the minimum key value (the root) to the output buffer. b) Let R be the next record in the input buff
23、er. If Rs key value is greater than the key value just output, thenReplace the root with this keyelseReplace the root with the record in array position LAST, and add the next record in the file to a new heap (actually, stick it at the end of the array). c) Sift down the root to recorder the heap.20:
24、4529See Figure 8.9 in page 28420:4530 1) Only the record whose key value is greater than the last key value output can be added to the heap. 2) The record with smaller key value can not be output as a part of the run, but is stored as the data to be handled for the next run; -Heap becomes smaller an
25、d smaller, and the discarded heap space is used to store the records not be output. 3) If the size of available RAM used by array is M, then the smallest run generated by Replacement selection sort is M and the average run is 2M. (Proven process see “Snowplow analogy”)20:4531Simple mergesort: Place runs into two files.Merge the first two ru
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年幼兒園教師學(xué)生健康監(jiān)測(cè)與疾病預(yù)防合同
- 迪慶云南迪慶香格里拉市招聘治安聯(lián)防人員80人筆試歷年參考題庫(kù)附帶答案詳解
- 蘇州江蘇蘇州大學(xué)納米科學(xué)技術(shù)學(xué)院課程助教招聘11人(202420252學(xué)期)筆試歷年參考題庫(kù)附帶答案詳解
- 舟山浙江舟山市普陀區(qū)機(jī)關(guān)事務(wù)管理中心編外人員招聘筆試歷年參考題庫(kù)附帶答案詳解
- 紅河2025年云南紅河金平縣人民法院招聘聘用制書記員司法警務(wù)輔助人員筆試歷年參考題庫(kù)附帶答案詳解
- 福建2025年福建水利電力職業(yè)技術(shù)學(xué)院招聘35人筆試歷年參考題庫(kù)附帶答案詳解
- 湖北2025年湖北民族大學(xué)人才引進(jìn)163人筆試歷年參考題庫(kù)附帶答案詳解
- 浙江2025年春季浙江省新時(shí)代自貿(mào)港研究院招聘筆試歷年參考題庫(kù)附帶答案詳解
- 河南2024年河南體育學(xué)院冬季運(yùn)動(dòng)管理中心人事代理招聘11人筆試歷年參考題庫(kù)附帶答案詳解
- 桂林2025年廣西桂林市事業(yè)單位招聘1462人筆試歷年參考題庫(kù)附帶答案詳解
- 2022年甘肅省蘭州市診斷考試(一診)數(shù)學(xué)試題(含答案解析)
- 工業(yè)企業(yè)職工聽(tīng)力保護(hù)規(guī)范
- 裝載機(jī)裝車施工方案
- 《工程估價(jià)》課程設(shè)計(jì)
- 語(yǔ)文新課標(biāo)背景下:六上《每日閱讀打卡表》(模板)
- 二年級(jí)綜合實(shí)踐活動(dòng)課件-我與蔬菜交朋友-全國(guó)通(41張)
- 血型與輸血檢驗(yàn)-臨床輸血(臨床檢驗(yàn)課件)
- 良性前列腺增生癥住院醫(yī)師規(guī)范化培訓(xùn)教學(xué)查房
- 高中數(shù)學(xué)知識(shí)點(diǎn)大全
- 人機(jī)料法環(huán)測(cè)5M1E分析法
- 游泳社會(huì)指導(dǎo)員專項(xiàng)理論考試復(fù)習(xí)題庫(kù)匯總(附答案)
評(píng)論
0/150
提交評(píng)論