<!DOCTYPE html>
    <html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
    <head>
<title>Sắp xếp trong Pascal &#40;tiếp theo&#41; - Sách Giải</title>
<meta name="description" content="Môn học">
<meta name="keywords" content="môn học">
<meta name="news_keywords" content="môn học">
<meta name="author" content="Sách Giải">
<meta name="copyright" content="Sách Giải [sachgiai2015@gmail.com]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index,archive,follow,noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="og:title" content="Sắp xếp trong Pascal &#40;tiếp theo&#41;">
<meta property="og:type" content="website">
<meta property="og:description" content="Môn học">
<meta property="og:site_name" content="Sách Giải">
<meta property="og:url" content="https://sachgiai.com/savefile/Tin-hoc/sap-xep-trong-pascal-tiep-theo-13458.html">
<link rel="shortcut icon" href="https://sachgiai.com/favicon.ico">
<link rel="canonical" href="https://sachgiai.com/savefile/Tin-hoc/sap-xep-trong-pascal-tiep-theo-13458.html">
<link rel="alternate" href="https://sachgiai.com/rss/" title="Môn học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-1/" title="Môn học - Lớp 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-1/" title="Môn học - Tiếng Việt 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-1/" title="Môn học - Toán 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-the-chat-1/" title="Môn học - Giáo dục thể chất 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/my-thuat-1/" title="Môn học - Mỹ thuật 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-1-ctst/" title="Môn học - Tiếng Việt 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-1-ctst/" title="Môn học - Toán 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/am-nhac-1/" title="Môn học - Âm nhạc 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-the-chat-1-cd/" title="Môn học - Giáo dục thể chất 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoat-dong-trai-nghiem-1/" title="Môn học - Hoạt động trải nghiệm 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-1-cd/" title="Môn học - Toán 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tu-nhien-va-xa-hoi-1/" title="Môn học - Tự nhiên và xã hội 1" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-2/" title="Môn học - Lớp 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-2/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-2/" title="Môn học - Toán 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-2/" title="Môn học - Tiếng Việt 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-51/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-2-ctst/" title="Môn học - Tiếng Việt 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-2-ctst/" title="Môn học - Toán 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-2/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-2-cd/" title="Môn học - Toán 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-2-cd/" title="Môn học - Tiếng Việt 2" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-3/" title="Môn học - Lớp 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-3/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-3/" title="Môn học - Tiếng Việt 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-3/" title="Môn học - Toán 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-3/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-3-cd/" title="Môn học - Tiếng Việt 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-3-cd/" title="Môn học - Toán 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-3/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-3-ctst/" title="Môn học - Tiếng Việt 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-3-ctst/" title="Môn học - Toán 3" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-4/" title="Môn học - Lớp 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-4/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-4/" title="Môn học - Tiếng Việt 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-4/" title="Môn học - Toán 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-4/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-4-ctst/" title="Môn học - Tiếng Việt 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-4-ctst/" title="Môn học - Toán 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-4/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-4-cd/" title="Môn học - Tiếng Việt 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-4-cd/" title="Môn học - Toán 4" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-5/" title="Môn học - Lớp 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-5/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-5/" title="Môn học - Tiếng Việt 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-5/" title="Môn học - Toán 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-5/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-5-cd/" title="Môn học - Tiếng Việt 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-5-cd/" title="Môn học - Toán 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-5/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-viet-5-ctst/" title="Môn học - Tiếng Việt 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-5-ctst/" title="Môn học - Toán 5" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-6/" title="Môn học - Lớp 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-6/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-6/" title="Môn học - Ngữ Văn 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-6/" title="Môn học - Toán 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-6-global-success/" title="Môn học - Tiếng Anh 6 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-va-dia-li-6/" title="Môn học - Lịch sử và Địa lí 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-6/" title="Môn học - Giáo dục công dân 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-6/" title="Môn học - Tin học 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-6/" title="Môn học - Cánh diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-6-cd/" title="Môn học - Giáo dục công dân 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-6-cd/" title="Môn học - Ngữ Văn 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-6-cd/" title="Môn học - Toán 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-6/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-6-ctst/" title="Môn học - Ngữ Văn 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-6-ctst/" title="Môn học - Toán 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-6-ctst/" title="Môn học - Giáo dục công dân 6" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-7/" title="Môn học - Lớp 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-7/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-7/" title="Môn học - Ngữ Văn 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-7/" title="Môn học - Toán 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-7-global-success/" title="Môn học - Tiếng Anh 7 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-7/" title="Môn học - Giáo dục công dân 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-va-dia-li-7/" title="Môn học - Lịch sử và Địa lí 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/khoa-hoc-tu-nhien-7/" title="Môn học - Khoa học tự nhiên 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-7/" title="Môn học - Tin học 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-7/" title="Môn học - Công nghệ 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-7/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-7-cd/" title="Môn học - Ngữ Văn 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-7-cd/" title="Môn học - Toán 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/khoa-hoc-tu-nhien-7-cd/" title="Môn học - Khoa học tự nhiên 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-7/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-7-ctst/" title="Môn học - Ngữ Văn 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-7-ctst/" title="Môn học - Toán 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/mi-thuat-7-ctst/" title="Môn học - Mĩ thuật 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/am-nhac-7-ctst/" title="Môn học - Âm nhạc 7" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-8/" title="Môn học - Lớp 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-8/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-8/" title="Môn học - Ngữ Văn 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-8/" title="Môn học - Toán 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/khoa-hoc-tu-nhien-8/" title="Môn học - Khoa học tự nhiên 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-8/" title="Môn học - Giáo dục công dân 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-8/" title="Môn học - Tin học 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-va-dia-li-8/" title="Môn học - Lịch sử và Địa lí 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-8/" title="Môn học - Công nghệ 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-8-global-success/" title="Môn học - Tiếng Anh 8 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-8/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-8-cd/" title="Môn học - Ngữ Văn 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-8-cd/" title="Môn học - Toán 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-dan-8-cd/" title="Môn học - Công Dân 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-8/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-8-ctst/" title="Môn học - Ngữ Văn 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-8-ctst/" title="Môn học - Toán 8" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-9/" title="Môn học - Lớp 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-9/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-9/" title="Môn học - Ngữ Văn 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-9/" title="Môn học - Toán 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/khoa-hoc-tu-nhien-9/" title="Môn học - Khoa học tự nhiên 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/giao-duc-cong-dan-9/" title="Môn học - Giáo dục công dân 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-9/" title="Môn học - Tin học 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-va-dia-li-9/" title="Môn học - Lịch sử và Địa lí 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-9-global-success/" title="Môn học - Tiếng Anh 9 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-9/" title="Môn học - Công nghệ 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-9/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-9-cd/" title="Môn học - Ngữ Văn 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-9-cd/" title="Môn học - Toán 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-9/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-9-ctst/" title="Môn học - Ngữ Văn 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-9-ctst/" title="Môn học - Toán 9" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-10/" title="Môn học - Lớp 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-10/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-10/" title="Môn học - Ngữ Văn 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-10/" title="Môn học - Toán 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-10/" title="Môn học - Kinh tế và Pháp luật 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-10-global-success/" title="Môn học - Tiếng Anh 10 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-10/" title="Môn học - Lịch Sử 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-10/" title="Môn học - Địa Lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-10/" title="Môn học - Vật Lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-10/" title="Môn học - Hoá học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-10/" title="Môn học - Sinh học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-trong-trot-10/" title="Môn học - Công nghệ trồng trọt 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-thiet-ke-10/" title="Môn học - Công nghệ thiết kế 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/quoc-phong-va-an-ninh-10/" title="Môn học - Quốc Phòng và An Ninh 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-10/" title="Môn học - Tin học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-10/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-10-cd/" title="Môn học - Ngữ Văn 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-10-cd/" title="Môn học - Toán 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-10-cd/" title="Môn học - Kinh tế và Pháp luật 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-10-cd/" title="Môn học - Tin học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-10-cd/" title="Môn học - Hoá học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-10-cd/" title="Môn học - Lịch sử 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-10-cd/" title="Môn học - Địa Lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-10-cd/" title="Môn học - Sinh học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-10-cd/" title="Môn học - Vật lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-10-explore-new-worlds/" title="Môn học - Tiếng Anh 10 Explore New Worlds" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-trong-trot-10-cd/" title="Môn học - Công nghệ trồng trọt 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-thiet-ke-10-cd/" title="Môn học - Công nghệ thiết kế 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-10/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-10-ctst/" title="Môn học - Ngữ Văn 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-10-ctst/" title="Môn học - Toán 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-10-ctst/" title="Môn học - Lịch Sử 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-10-ctst/" title="Môn học - Địa Lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-10-ctst/" title="Môn học - Sinh học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-10-ctst/" title="Môn học - Vật Lí 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-10-ctst/" title="Môn học - Hoá học 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/quoc-phong-va-an-ninh-10-ctst/" title="Môn học - Quốc Phòng và An Ninh 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-10-ctst/" title="Môn học - Kinh tế và Pháp luật 10" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-10-friends-plus/" title="Môn học - Tiếng Anh 10 Friends plus" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-11/" title="Môn học - Lớp 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-11/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-11/" title="Môn học - Ngữ Văn 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-11/" title="Môn học - Toán 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-11/" title="Môn học - Hoá học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-11/" title="Môn học - Sinh học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-11/" title="Môn học - Địa Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-11/" title="Môn học - Lịch Sử 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-11/" title="Môn học - Vật Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-11/" title="Môn học - Kinh tế và Pháp luật 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-11-chan-nuoi/" title="Môn học - Công nghệ 11 Chăn nuôi" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-11-co-khi/" title="Môn học - Công nghệ 11 Cơ khí" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-11-ung-dung/" title="Môn học - Tin học 11 Ứng dụng" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-11-khoa-hoc-may-tinh/" title="Môn học - Tin học 11 Khoa học máy tính" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-11-global-success/" title="Môn học - Tiếng Anh 11 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-11/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-11-cd/" title="Môn học - Ngữ Văn 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-11-cd/" title="Môn học - Toán 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-11-cd/" title="Môn học - Hoá học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-11-cd/" title="Môn học - Lịch Sử 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-11-cd/" title="Môn học - Địa Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-11-cd/" title="Môn học - Sinh học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-11-cd/" title="Môn học - Vật Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-11-ung-dung-cd/" title="Môn học - Tin học 11 Ứng dụng" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-11-khoa-hoc-may-tinh-cd/" title="Môn học - Tin học 11 Khoa học máy tính" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-11-explore-new-worlds/" title="Môn học - Tiếng Anh 11 Explore New Worlds" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/quoc-phong-va-an-ninh-11-cd/" title="Môn học - Quốc phòng và An ninh 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-11-cd/" title="Môn học - Kinh tế và Pháp luật 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-11-chan-nuoi-cd/" title="Môn học - Công nghệ 11 Chăn nuôi" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-11-co-khi-cd/" title="Môn học - Công nghệ 11 Cơ khí" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-11/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-11-ctst/" title="Môn học - Ngữ Văn 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-11-ctst/" title="Môn học - Toán 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-11-ctst/" title="Môn học - Địa Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-11-ctst/" title="Môn học - Hoá học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-11-ctst/" title="Môn học - Sinh học 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-11-ctst/" title="Môn học - Lịch Sử 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-11-ctst/" title="Môn học - Kinh tế và Pháp luật 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-11-friends-plus/" title="Môn học - Tiếng Anh 11 Friends plus" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-11-ctst/" title="Môn học - Vật Lí 11" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lop-12/" title="Môn học - Lớp 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ket-noi-tri-thuc-12/" title="Môn học - Kết nối tri thức" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-12/" title="Môn học - Ngữ Văn 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-12/" title="Môn học - Toán 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/dia-li-12/" title="Môn học - Địa Lí 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/hoa-hoc-12/" title="Môn học - Hoá học 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/lich-su-12/" title="Môn học - Lịch Sử 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/sinh-hoc-12/" title="Môn học - Sinh học 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/vat-li-12/" title="Môn học - Vật Lí 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tieng-anh-12-global-success/" title="Môn học - Tiếng Anh 12 Global Success" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-12-ung-dung/" title="Môn học - Tin học 12 Ứng dụng" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tin-hoc-12-khoa-hoc-may-tinh/" title="Môn học - Tin học 12 Khoa học máy tính" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/kinh-te-va-phap-luat-12/" title="Môn học - Kinh tế và Pháp luật 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-12-chan-nuoi/" title="Môn học - Công nghệ 12 Chăn nuôi" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/cong-nghe-12-co-khi/" title="Môn học - Công nghệ 12 Cơ khí" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/canh-dieu-12/" title="Môn học - Cánh Diều" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-12-cd/" title="Môn học - Ngữ Văn 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-12-cd/" title="Môn học - Toán 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/chan-troi-sang-tao-12/" title="Môn học - Chân trời sáng tạo" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/ngu-van-12-ctst/" title="Môn học - Ngữ Văn 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/toan-12-ctst/" title="Môn học - Toán 12" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Toan-hoc/" title="Môn học - Toán học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Van-hoc/" title="Môn học - Văn học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Vat-ly/" title="Môn học - Vật lý" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Hoa-hoc/" title="Môn học - Hoá học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Lich-su/" title="Môn học - Lịch sử" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Dia-ly/" title="Môn học - Địa lý" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Anh-van/" title="Môn học - Anh văn" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Cong-nghe/" title="Môn học - Công nghệ" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Sinh-hoc/" title="Môn học - Sinh học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Tin-hoc/" title="Môn học - Tin học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Am-nhac/" title="Môn học - Âm nhạc" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Mi-thuat/" title="Môn học - Mĩ thuật" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/The-duc/" title="Môn học - Thể dục" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Cong-dan/" title="Môn học - Công dân" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/khoa-hoc/" title="Môn học - Khoa học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Y-khoa/" title="Môn học - Y khoa" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Ngoai-khoa/" title="Môn học - Ngoại khoá" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Guong-sang/" title="Môn học - Gương sáng" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/De-thi-dap-an/" title="Môn học - Đề thi, đáp án" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Tho-van/" title="Môn học - Thơ văn" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/De-tai/" title="Môn học - Đề tài" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Day-va-hoc/" title="Môn học - Dạy và học" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/Hoi-dap/" title="Môn học - Hỏi đáp" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/doc/" title="Môn học - Văn bản" type="application/rss+xml">
<link rel="alternate" href="https://sachgiai.com/rss/tong-hop/" title="Môn học - Tổng hợp" type="application/rss+xml">
<link rel="preload" as="style" href="https://sachgiai.com/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://sachgiai.com/themes/whitebook/css/bootstrap.min.css" type="text/css">
<link rel="preload" as="style" href="https://sachgiai.com/themes/whitebook/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://sachgiai.com/themes/whitebook/css/style.responsive.css" type="text/css">
<link rel="preload" as="style" href="https://sachgiai.com/themes/whitebook/css/news.css" type="text/css">
<link rel="preload" as="style" href="https://sachgiai.com/themes/whitebook/css/custom.css" type="text/css">
<link rel="preload" as="script" href="https://sachgiai.com/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/themes/whitebook/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/themes/whitebook/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/themes/whitebook/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.googletagmanager.com/gtag/js?id=G-1KVL9TDN71" type="text/javascript">
<link rel="preload" as="script" href="https://sachgiai.com/themes/whitebook/js/bootstrap.min.js" type="text/javascript">
<link rel="stylesheet" href="https://sachgiai.com/assets/css/font-awesome.min.css">
<link rel="stylesheet" href="https://sachgiai.com/themes/whitebook/css/bootstrap.min.css">
<link rel="stylesheet" href="https://sachgiai.com/themes/whitebook/css/style.css">
<link rel="stylesheet" href="https://sachgiai.com/themes/whitebook/css/style.responsive.css">
<link rel="StyleSheet" href="https://sachgiai.com/themes/whitebook/css/news.css">
<link rel="stylesheet" href="https://sachgiai.com/themes/whitebook/css/custom.css">
<style>
	body{background: #fff;}
</style>
<!-- Google Tag Manager -->
<!-- End Google Tag Manager -->
</head>
    <body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PMHW5CD"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">Sách Giải</h2>
		<p class="pull-right"><a title="Sách Giải" href="https://sachgiai.com/">https://sachgiai.com</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Sắp xếp trong Pascal &#40;tiếp theo&#41;</h1>
		<ul class="list-inline">
			<li>Thứ năm - 06/08/2020 09:35</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
			Nội dung của phương pháp này là chia dãy cần sắp thành các dãy con đã có thứ tự (gọi là các Run) và có số phần tử là lũy thừa của 2, sau đó tìm cách trộn dần chúng với nhau thành các Run có thứ tự có chiều dài tăng dần cho đến khi chỉ còn một Run thì quá trình sắp xếp kết thúc.
		</div>
		<div id="bodytext" class="clearfix">
			<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b>f) Phương pháp trộn (Merging sort)</b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><i>* Giải thích:</i></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Nội dung của phương pháp này là chia dãy cần sắp thành các dãy con đã có thứ tự (gọi là các Run) và có số phần tử là lũy thừa của 2, sau đó tìm cách trộn dần chúng với nhau thành các Run có thứ tự có chiều dài tăng dần cho đến khi chỉ còn một Run thì quá trình sắp xếp kết thúc.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Ta có giải thuật sau đây để trộn 2 Run X và y cùng thứ tự có chiều dài lần lượt là m và n thành một Run z có chiều dài là m + n.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Procedure Merge;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; i, j, k: integer;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; i:= 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; j:= 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; k:= 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; while (i &lt;= m) and (j &lt;= n) do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If x&#91;i&#93; &lt; y&#91;j&#93; then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z&#91;k&#93;:= x&#91;i&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i := i + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z&#91;k&#93;:= y&#91;j&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j := j + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k:= k + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; while i &lt;= m do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z&#91;k&#93; := x&#91;j&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k := k + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := k + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := i + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; while j &lt;= n do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z&#91;k&#93;:= y&#91;j&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k := k + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j := j + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">End;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Cụ thể là nếu ta phải sắp xếp dãy: a&#91;l&#93;, a&#91;2&#93;, a&#91;n&#93;.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Ta sử dụng 2*n phần tử được chia thành hai vùng. Vùng 1 gồm các phần tử a&#91;l&#93;..a&#91;n&#93;, vùng 2 gồm các phần tử a&#91;n+1&#93;..a&#91;2*n|. Ta trộn các Run từ vùng này và phân phối vào vùng kia. Khi trộn và phân phối, ta trộn các Run ngược chiều nhau của vùng trộn và phân phối luân phiên vào 2 đầu của vùng phân phối bước kế tiếp dễ trộn hơn. Quá trình sắp xếp sẽ kết thúc nếu vùng phân phối chỉ còn một Run. Khi kết thúc, nếu vùng phân phối gồm các phần tử a&#91;n+l&#93;..a&#91;2*n&#93; thì ta chép dãy a&#91;n+1&#93;..a&#91;2*n&#93; vào dãy a&#91;l&#93;..a&#91;n&#93;.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><i><u>* Ví dụ:</u></i></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Sắp xếp dãy số:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 89 &nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 62</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 1: Vùng 1 là vùng trộn, vùng 2 là vùng phân phối:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 1:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 89 &nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 62</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt; &nbsp;&nbsp;&nbsp;&nbsp; -&gt; &nbsp;&nbsp;&nbsp;&nbsp; -&gt; &nbsp;&nbsp;&nbsp;&nbsp; -&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-&nbsp; &nbsp;&nbsp;&nbsp; &lt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 89 &nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 1</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ———&gt;&nbsp; &nbsp;&nbsp;&nbsp; ———&gt;&nbsp; &nbsp;&nbsp;&nbsp; &lt;———&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;———</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 2: Vùng 2 là vùng trộn, vùng 1 là vùng phân phối:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 39&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 62&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 89&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ———&gt;&nbsp; &nbsp;&nbsp;&nbsp; ———&gt;&nbsp; &nbsp;&nbsp;&nbsp; &lt;———&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;———</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 1: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 89 &nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 7</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ————————&gt;&nbsp; &nbsp;&nbsp;&nbsp; &lt;————————</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Bước 3: Vùng 1 là vùng trộn, vùng 2 là vùng phân phối:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 1: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 89&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 7</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ——————————————————&gt;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 89</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 4: Chép các phần tử của vùng 2 vào vùng 1:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 2: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 89</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng 1: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13 &nbsp;&nbsp;&nbsp;&nbsp; 37 &nbsp;&nbsp;&nbsp;&nbsp; 39 &nbsp;&nbsp;&nbsp;&nbsp; 50 &nbsp;&nbsp;&nbsp;&nbsp; 62 &nbsp;&nbsp;&nbsp;&nbsp; 89</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><i>* Thể hiện bằng PASCAL:</i></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><u>CHÚ Ý:</u></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Ta khai báo:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var a: array&#91;1..2* n&#93; of item ;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Đặt up: Bollean</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; up = True: vùng 1 là vùng trộn, vùng 2 là vùng phân phối.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; up = false: vùng 2 là vùng trộn, vùng 1 là vùng phân phối.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; d: cho biết chiều phân phôi</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; d = 1: chiều phân phôi tăng dần.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; d = -1: chiều phân phối giảm dần.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; p = chiều dài của run khi trộn.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; m = số phần tử chưa được trộn và phân phối.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; s, t = chiều dài của hai run đang trộn.</span></span></span>
<table class="MsoTableGrid" style="margin-left:36px; border-collapse:collapse; border:none">
	<tbody>
		<tr>
			<td style="border-bottom:none; width:151px; padding:0cm 7px 0cm 7px; border-top:none; border-right:1px solid black; border-left:none" valign="top"><span style="font-size:14pt"><span style="line-height:normal"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng trộn</span></span></span></td>
			<td style="border-bottom:1px solid black; width:85px; padding:0cm 7px 0cm 7px; border-top:1px solid black; border-right:1px solid black; border-left:none" valign="top">&nbsp;</td>
		</tr>
		<tr>
			<td style="border-bottom:none; width:151px; padding:0cm 7px 0cm 7px; border-top:none; border-right:1px solid black; border-left:none" valign="top"><span style="font-size:14pt"><span style="line-height:normal"><span style="font-family:&#039;Times New Roman&#039;,serif">Vùng phân phối</span></span></span></td>
			<td style="border-bottom:1px solid black; width:85px; padding:0cm 7px 0cm 7px; border-top:none; border-right:1px solid black; border-left:none" valign="top">&nbsp;</td>
		</tr>
	</tbody>
</table>
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Cụ thể là:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Procedure Merge_Sort;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; up: Bollean;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; i, j, k, q, t, r, s, d, p: integer;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; up := true;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; p := 1</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; repeat</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d := 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m := n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if up then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := 1; j := n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k := n + 1; q := 2* n</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i:= n + 1; j:= 2 * n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k:= 1; q:= n</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Repeat</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if m &gt;= p then s := p else s := m; m:= m - s</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&#039; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (s &lt; &gt; 0) and (r &lt; &gt; 0) do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if a&#91;i&#93;.key &lt; a&#91;j&#93;.key then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&#91;k&#93; := a&#91;i&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := i + 1; s := s - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&#91;k&#93;:= a&#91;j&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j := j - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r := r - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k:= k + d;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while s &lt; &gt; do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&#91;k&#93;:= a&#91;i&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k := k + d;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := i + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s := s - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while r &lt; &gt; 0 do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a&#91;k&#93;:= a&#91;j&#93;;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; k:= k + d;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j := j - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r := r - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d := -d;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; t := k; k := q; q := 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; until m = 0;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; up := &nbsp;not up;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p := 2*p</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; until p &gt;= n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not up then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i := 1 to n do a&#91;i&#93;:= a&#91;i + n&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">end;</span></span></span><br />
<br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b>3. SẮP XẾP NGOÀI (SẮP XẾP TẬP TIN)</b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><i>a) Khái niệm</i></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Tất cả các phương pháp sắp xếp trong đã trình bày ở trên đều đòi hỏi phải đưa toàn bộ dữ liệu cần sắp vào bộ nhớ chính nên không thể dùng để sắp thứ tự các tập tin có chiều dài tương đối lớn vì không thể nạp toàn bộ tập tin vào bộ nhớ chính để sắp xếp, do đó ta phải có phương pháp khác thích hợp cho việc sắp xếp các tập tin.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Phương pháp căn bản để sắp xếp một tập tin là:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Phân chia tập tin nguồn thành các tập tin nhỏ hơn,</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Nạp vào các tập tin đó vào bộ nhớ chính.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Dùng các phương pháp sắp xếp trong để sắp xếp chúng thành các run.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Trộn các run này lại và đưa vào tập tin đích. </span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Trong đó hai bước quan trọng nhất là:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Tạo các run ban đầu.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">- Trộn các run với nhau.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Để đơn giản hóa vấn đề ở đây ta chỉ xét các phương pháp trộn run kích thước cố định của dãy.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><i>b) Ví dụ</i></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Ta xét 3 tập tin f&#91;0&#93;, i&#91;1&#93;, f&#91;2&#93; với f&#91;0&#93; là tập tin cần sắp xếp. Ta sẽ phân phối các run của f&#91;0&#93;ư và f&#91;l&#93;, f&#91;2&#93; và trộn các run này vào tập tin f&#91;0&#93;. Nếu sau khi trộn mà f&#91;0&#93; chỉ có một run thì kết thúc thuật giải. Ngược lại nếu f&#91;0&#93; có nhiều hơn một run thì ta lặp lại bước phân phôi và trộn các run.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Ban đầu, f&#91;0&#93; chứa các khóa:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">17 31 05 59 13 41 43 67 11 23 29 47 03 07 71 02 19 57 37 61</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 1: Phân phối các run có chiều dài bằng 1 của f&#91;0&#93; vào f&#91;1&#93; và f&#91;2&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;1&#93;&nbsp;&nbsp;&nbsp; <u>17</u>&nbsp;&nbsp; <u>05</u>&nbsp;&nbsp; <u>13</u>&nbsp;&nbsp; <u>43</u>&nbsp;&nbsp; <u>11</u>&nbsp;&nbsp; <u>29</u>&nbsp;&nbsp; <u>03</u>&nbsp;&nbsp; <u>71</u>&nbsp;&nbsp; <u>19</u>&nbsp;&nbsp; <u>37</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;2&#93;&nbsp;&nbsp;&nbsp; <u>31</u>&nbsp;&nbsp; <u>59</u>&nbsp;&nbsp; <u>41</u>&nbsp;&nbsp; <u>67</u>&nbsp; &nbsp;<u>23</u>&nbsp;&nbsp; <u>47</u>&nbsp;&nbsp; <u>07</u>&nbsp;&nbsp; <u>02</u>&nbsp;&nbsp; <u>57</u>&nbsp;&nbsp; <u>61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 2: Trộn các run của f&#91;1&#93; và f&#91;2&#93; vào f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">F&#91;0&#93;&nbsp;&nbsp; <u>17 31</u> &nbsp;&nbsp;<u>05 59</u> &nbsp;&nbsp;&nbsp;<u>13 41</u> &nbsp;&nbsp;&nbsp;<u>43 67</u> &nbsp;&nbsp;<u>11 23</u> &nbsp;&nbsp;&nbsp;<u>29 47</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u>03 07</u> &nbsp;&nbsp;<u>02 71</u> &nbsp;&nbsp;&nbsp;<u>19 57</u> &nbsp;&nbsp;&nbsp;<u>37 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 3 :&nbsp;&nbsp;&nbsp; Phân phối các run cỏ chiều dài bằng 2 của f&#91;0&#93; vào f&#91;l&#93; và f&#91;2&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;1&#93;&nbsp;&nbsp;&nbsp; <u>13 31</u> &nbsp; <u>14 41</u>&nbsp;&nbsp; <u>11 23</u> &nbsp;&nbsp;&nbsp;<u>03 07</u>&nbsp;&nbsp; <u>19 57</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;2&#93;&nbsp;&nbsp;&nbsp; <u>05 59</u> &nbsp;&nbsp;<u>43 67</u>&nbsp;&nbsp; <u>29 47</u> &nbsp;&nbsp;&nbsp;<u>02 71</u> &nbsp;&nbsp;<u>37 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 4 :&nbsp;&nbsp;&nbsp; Trộn các run&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; của f&#91;l&#93; và f&#91;2&#93; vào f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;0&#93;&nbsp;&nbsp;&nbsp; <u>05 17 31 59</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <u>13 41 43 67</u>&nbsp;&nbsp;&nbsp; <u>11 23 29 47</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u>02 03 07 71</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <u>19 37 57 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 5 :&nbsp;&nbsp;&nbsp; Phân phối các run có chiều dài bằng 4 của f&#91;0&#93; vào f&#91;l&#93; và f&#91;2&#93;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;l&#93;&nbsp;&nbsp;&nbsp;&nbsp; <u>05 17 31 59</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <u>11 23 29 47</u> &nbsp;&nbsp;<u>19 37 57 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;2&#93;&nbsp;&nbsp;&nbsp; <u>13 41 43 67</u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <u>02 03 07 71</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 6: Trộn các run của f&#91;1&#93; và f&#91;2&#93; vào f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;0&#93; &nbsp;&nbsp; <u>05 13 17 31</u> &nbsp;&nbsp;&nbsp;<u>41 43 59 67</u> &nbsp;&nbsp;<u>02 03 07 11</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u>23 29 47 71</u> &nbsp;&nbsp;&nbsp;<u>19 37 57 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 7: Phân phối các run có chiều dài bằng 8 của f&#91;0&#93; vào f&#91;1&#93; và f&#91;2&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;1&#93; &nbsp;&nbsp; <u>05 13 17 31</u> &nbsp;&nbsp;&nbsp;<u>41 43 59 67</u> <u>19 37 57 61</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;2&#93; &nbsp;&nbsp; <u>02 03 07 11</u> &nbsp;&nbsp;&nbsp;<u>23 29 47 71</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 8: Trộn các run của f&#91;l&#93; và f&#91;2&#93; vào f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;0&#93;&nbsp;&nbsp;&nbsp; 02 03 05 07 &nbsp;&nbsp;&nbsp;11 13 17 23 &nbsp;&nbsp;&nbsp;29 31 41 43 &nbsp;&nbsp;&nbsp;47 59 67 71</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19 37 57 61</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 9: Phân phối các run có chiều dài bằng 16 của f&#91;0&#93; vào f&#91;1&#93; và f&#91;2&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;1&#93; <u>02 03 05 07 11 13 17 23 29 31 41 43 47 59 67 71</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;2&#93; <u>19 37 57 61</u></span></span></span><br />
<br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">• Bước 10: Trộn các run của f&#91;1&#93; và f&#91;2&#93; vào f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f&#91;0&#93; <u>02 03 05 07 11 13 17 19 23 29 31 37 41 43 47 57</u></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <u>59 61 67 71</u></span></span></span><br />
<br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Ta khai báo:</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Type</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; tape = file of item;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">f: array&#91;0..2&#93; of tape;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Gọi: n - số mẫu tin của tập tin f&#91;0&#93;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Thủ tục Distribute phân phối các run có chiều dài bằng p của f&#91;0&#93; luân phiên vào f&#91;1&#93; và f&#91;2J.</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif"><b><i>c) Thể hiện bằng PASCAL:</i></b></span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Procedure Merge_Sort;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; p, q, r, m: integer;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; x1, x2: item;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Procedure Distribute (p: integer);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">{Phân phôi các run có chiều dài bằng p của f&#91;0&#93; vào f&#91;1&#93; và f&#91;2&#93;}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">Var</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; k, i: integer;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; buf: item;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; reset (f&#91;0&#93;); rewrite (f&#91;1&#93;); rewrite (f&#91;2&#93;);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; k := 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; i := 0; .</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">while not eof (f&#91;0&#93;) do</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := i + 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read (f&#91;0&#93;, buf);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (f&#91;k&#93;, buf);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if i = p then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i := 0;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if k = 1 then k:= 2 else k:= 1</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp; rewrite (f&#91;0&#93;); reset (f&#91;1&#93;); reset (f&#91;2&#93;);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;end; {Distribute}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">BEGIN (Merge.Sortl</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp; p:= 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp; repeat</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp; {phân phối các run có chiều dài bằng p của f&#91;0&#93; vào f&#91;1&#93; và f&#91;2&#93;) ;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; Distribute(p)</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; m:= n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; read (f&#91;1&#93;, x1) ; {run q}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; read (f&#91;2&#93;, x2) ; {run r}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; repeat </span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; if m &gt;= p then q := p else q := m;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; m := m - q;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; if m &gt;= p then r := p else r := m;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; m := m - r;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; while (p &lt; &gt; 0) and (r &lt; &gt; 0) do {chưa hết run q và run r}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if x1.key &lt; x2.key then</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (f&#91;0&#93;, x1);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q := q - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not eof (f&#91;1&#93;) then read (f&#91;1&#93;, x1) ;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (f&#91;0&#93;, x2);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r := r - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not eof (f&#91;2&#93;) then read x2):</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while q &lt; &gt; 0 do {chưa hết run q}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write (f&#91;0&#93;, x1);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q := q - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not eof (f&#91;1&#93;) then read (f&#91;1&#93;, x1);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while r &lt; &gt; 0 do {chưa hết run r}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write (f&#91;0&#93;, x2);</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r := r - 1;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if not eof (f&#91;2&#93; then read (f&#91;2&#93;, x2) ,</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; until m = 0;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p := 2*p ; {tăng chiều dài của run}</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">&nbsp;&nbsp;&nbsp; until p &gt;= n;</span></span></span><br />
<span style="font-size:14pt"><span style="line-height:107%"><span style="font-family:&#039;Times New Roman&#039;,serif">END;</span></span></span><br />
<br />
&nbsp;
		</div>
				<div class="copyright">
			Bản quyền bài viết thuộc về <a href="https://sachgiai.com">Sachgiai.com</a>. Ghi nguồn Sách giải.com khi đăng lại bài viết này.
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://sachgiai.com/savefile/Tin-hoc/sap-xep-trong-pascal-tiep-theo-13458.html" title="Sắp xếp trong Pascal &#40;tiếp theo&#41;">https://sachgiai.com/savefile/Tin-hoc/sap-xep-trong-pascal-tiep-theo-13458.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; Sách Giải
		</div>
		<div id="contact">
			<a href="mailto:sachgiai2015@gmail.com">sachgiai2015@gmail.com</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://sachgiai.com/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<script src="https://sachgiai.com/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="nv3c_Fsp0c",nv_check_pass_mstime=3538000,nv_area_admin=0,nv_safemode=0,theme_responsive=1,nv_recaptcha_ver=2,nv_recaptcha_sitekey="6LfJY60ZAAAAAIWdlphAn4Y3Vz9PjefcOrgz8WDV",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://sachgiai.com/assets/js/language/vi.js"></script>
<script src="https://sachgiai.com/assets/js/DOMPurify/purify3.js"></script>
<script src="https://sachgiai.com/assets/js/global.js"></script>
<script src="https://sachgiai.com/assets/js/site.js"></script>
<script src="https://sachgiai.com/themes/whitebook/js/news.js"></script>
<script src="https://sachgiai.com/themes/whitebook/js/main.js"></script>
<script src="https://sachgiai.com/themes/whitebook/js/custom.js"></script>
<script type="application/ld+json">
        {
            "@context": "https://schema.org",
            "@type": "Organization",
            "url": "https://sachgiai.com",
            "logo": "https://sachgiai.com/uploads/sach-giai-com-logo.png"
        }
        </script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
			 (adsbygoogle = window.adsbygoogle || []).push({
				  google_ad_client: "ca-pub-7282572069040310",
				  enable_page_level_ads: true
			 });
        </script>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PMHW5CD');</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1KVL9TDN71"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date);gtag('config','G-1KVL9TDN71');</script>
<script src="https://sachgiai.com/themes/whitebook/js/bootstrap.min.js"></script>
</body>
</html>