Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:42:35+00:00 2026-06-02T19:42:35+00:00

I got this from a link which talks about external merge sort. From slide

  • 0

I got this from a link which talks about external merge sort.

From slide 6 Example: with 5 buffer pages, to sort 108 page file

  • Pass0: [108/5] = 22 sorted runs of 5 pages each (last run only with 3 pages)

  • Pass1 [22/4] = 6 sorted runs of 20 pages each (last run only with 8 pages)

  • Pass2: [6/3] = 2 sorted runs, 80 pages and 28 pages

  • Pass 3: [2/2] = 1 Sorted file of 108 pages

Question: My understanding is in external merge sort, in pass 0 you create chunks and then sort each chunk. In remaining passes you keep merging them.
So, applying that to the above example, since we have only 5 buffer pages, in Pass 0 its clear we need 22 sorted runs of 5 pages each.

  1. Now, why are we doing sorted runs for remaining passes instead or merging ?

  2. How come it tells for pass 1, 6 sorted runs of 20 pages each when we have only 5 buffer pages ?

  3. Where exactly is merge happening here ? and how is N reducing in each pass i.e from 108 to 22 to 6 to 2 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:42:37+00:00Added an answer on June 2, 2026 at 7:42 pm

    External Merge Sort is necessary when you cannot store all the data into memory. The best you can do is break the data into sorted runs and merge the runs in subsequent passes. The length of a run is tied to your available buffer size.

    Pass0: you are doing the operations IN PLACE. So you load 5 pages of data into the buffers and then sort it in place using an in place sorting algorithm.
    These 5 pages will be stored together as a run.

    Following passes: you can no longer do the operations in place since you’re merging runs of many pages. 4 pages are loaded into the buffers and the 5th is the write buffer. The merging is identical to the merge sort algorithm, but you will be dividing and conquering by a factor of B-1 instead of 2. When the write buffer is filled, it is written to disk and the next page is started.

    Complexity:
    When analyzing the complexity of external merge sort, the number of I/Os is what is being considered. In each pass, you must read a page and write the page. Let N be the number of pages. Each run will cost 2N. Read the page, write the page.
    Let B be the number of pages you can hold buffer space and N be the number of pages.
    There will be ceil(log_B-1(ceil(N/B))) passes. Each pass will have 2N I/Os. So O(nlogn).

    In each pass, the page length of a run is increasing by a factor of B-1, and the number of sorted runs is decreasing by a factor of B-1.
    Pass0: ceil(108 / 5) = 22, 5 pages per run
    Pass1: ceil(22 / 4) = 6, 20 pages per run
    Pass2: ceil(6 / 4 ) = 2, 80 pages per run
    Pass3: ceil(2 / 4 ) = 1 – done, 1 run of 108 pages

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this formula from a data structure book in the bubble sort algorithm.
I've got this jQuery function, which works to embed links from Youtube: $.fn.youtube =
Previously I asked this question and got back this BeautifulSoup example code, which after
I got this from php.net website. This is related to the problem I am
I got this from for a login form tutorial: function sanitize($securitystring) { $securitystring =
Somewhere some guy said (I honestly do not know where I got this from),
I got this code from the wordpress <head profile=http://gmpg.org/xfn/11> What does this means? what
I got this question from my cousin: What will be the best way to
I got this error from XCode: objc[8422]: FREED(id): message release sent to freed object=0x3b120c0
I got this code from someone, it's almost perfect to create a dynamic breadcrumb,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.