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 8380479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:28:08+00:00 2026-06-09T16:28:08+00:00

For merge-sort divide and conquer operations, how much time is required in bottom up

  • 0

For merge-sort divide and conquer operations, how much time is required in bottom up merging phase? My instructor says that it is be linear, hence it will be O(n). But I didn’t get it. How will it be linear?

How will merging operation be linear O(n)?

  • 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-09T16:28:09+00:00Added an answer on June 9, 2026 at 4:28 pm

    Merge operation of two arrays, is scanning arrays and picking the lowest/highest of two.

    so you have

    a: [1, 3, 6, 7]
    b: [4, 5, 7, 8]
    

    you compare like this (sort of pseudo code)

    indexA = 0;
    indexB = 0;
    auxilaryArray = [];
    indexAux = 0;
    
    while true 
       if indexA > len(a)-1 or indexb > len(b) -1  
           break
       # you are cherry picking one from the two array which is lesser
       # until any one of these array exausts
       if(a[indexA] > b[indexB])
           auxilaryArray[indexAux++] = b[indexB++]
       else
           auxilaryArray[indexAux++] = a[indexA++]
    
    #append the remaining array 
    while indexA < len(a)
        auxilaryArray[indexAux++] = a[indexA++]
    
    #appends the remaining array
    while indexB < len(b)
        auxilaryArray[indexAux++] = b[indexB++]
    

    you see if array a[k], and b[m] the sum of iterations by the three loops will be k+m.


    In case

    a: [1, 3, 6, 7]
    b: [4, 5, 7, 8]
    

    Here is the first loop for this:

    (0, 0), (1, 0), (2, 0), (2, 1), (2, 2), (3, 2) # 6 iterations; array a exhausted
    

    The second loop does not run since a is already scanned.

    The third loop appends

    b[2], b[3]   # 2 iterations; b exhaused
    

    You see 8 = 4 + 4 loops running? What’s the order O(n).


    In Mergesort the divide operation is logarithmic, ln n — the merge part is linear. Since you divide and merge back the order becomes multiplicative so Mergesort is O(nln(n)).

    Unlike Bubble, Selection, Insertion sort where you scan left to right (O(n)) and then fit the right candidate by consecutive swaps (bubble), or by scanning the minimum in rest of the the unsorted array (selection), or by inserting at right place in sorted part of the array (insertion) — these operations are O(n)… so the overall order of these algos becomes O(n2)

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

Sidebar

Related Questions

I know that the running time of merge sort is O(n*lg(n)) and that merge
I'm trying to write a merge-sort function that takes a list and a comparison
I want to compare count of operations of the sorting algorithms Merge Sort and
Is there a sorting algorithm that is named binary sort? Like merge sort, selection
I don't understand: why is my insertion sort implementation beating merge sort every time,
in merge sort, we always divide the array twice. why dont we divide it
from wiki page of insertion sort: Some divide-and-conquer algorithms such as quicksort and mergesort
The common wisdom says that for small enough arrays insertion sort is the best.
I've wrote a MIPS subroutine that implements the merge sort algorithm (the code is
Snape’s Unfriendly Algorithms for Wizards textbook claims the running time of merge sort is

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.