久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

PostgreSQL中REPLACEMENT SELECTION SORT使用與哪種情況

162次閱讀
沒有評論

共計 1651 個字符,預計需要花費 5 分鐘才能閱讀完成。

本篇內容主要講解“PostgreSQL 中 REPLACEMENT SELECTION SORT 使用與哪種情況”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“PostgreSQL 中 REPLACEMENT SELECTION SORT 使用與哪種情況”吧!

REPLACEMENT SELECTION SORT, 適用于內存較小的情況 (在高德納提出該算法的年代, 內存比起現在少了 N 個數量級).
該算法在 PG 9.x 或以下版本在使用, 在高版本已被廢棄. 其算法實現如下:

Let m be the number of records to be sorted which can be kept in the main memory. Imagine that these memory locations are registers and assume we can mark them as“on”or“off”. Replacement selection can overlap reading, sorting and writing.

Step1: The m registers are filled with records from the input to be sorted.
Step2: All registers are put into the “on” state.
Step3: Select the register which has the smallest of all “on” registers.
Step4: Transfer the contents of the selected register to the output (call it as key Y).
Step5: Replace the contents of the selected register by the next input record.
 If new record key   Y
 Go to step 3
 If new record key = =Y
 Go to step 4
 If new record key   Y
 Go to step 6
Step6: Turn the selected key register “off”.
 If all registers are now “off” We have completed a sorted substring(run).
 We start a new substring group and go to step 2.
 Else
 Go to step 3

下面是該算法的一個例子:

Example: Suppose number of registers is 3 and input keys are 5, 2, 9, 7, 0, 8, 1, 6, 3, 4 ...
 Registers Output
 5 2 9 2
 5 7 9 5
*0 7 9 7
*0 8 9 8
*0*1 9 9
*0*1*6
0 1 6 0
3 1 6 1
3 4 6 3
- 4 6 4
- - 6 6
- - -

相關的數據結構: 兩個數組, 一個存儲讀取的實際數據, 一個標記數組; 一個外存, 用于存儲已完成排序的一個 run.
如標記數組全為 F(非活動狀態), 則產生一個 run, 周而復始, 直至所有輸入被耗盡為止.
通過這個方法, 可以生成 N 個 runs(每個 run 對應的是已完成排序的部分數據).

CS 351 -Data Organization and Management (Section: 02)
External_sorting
replacement-selection-sort vs selection-sort

到此,相信大家對“PostgreSQL 中 REPLACEMENT SELECTION SORT 使用與哪種情況”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-24發表,共計1651字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 桃园市| 新河县| 怀集县| 石景山区| 永丰县| 城固县| 得荣县| 盐亭县| 进贤县| 昌乐县| 奈曼旗| 惠水县| 文成县| 琼结县| 休宁县| 广平县| 云梦县| 玛纳斯县| 辰溪县| 丘北县| 博野县| 广东省| 文山县| 德阳市| 贡觉县| 彰化县| 五台县| 昌黎县| 泉州市| 上栗县| 凤城市| 环江| 台中县| 余庆县| 济南市| 乌拉特后旗| 蕲春县| 中阳县| 乃东县| 阜新市| 西林县|