Why is merge sort good for large inputs?

This is the text from Data Structures and Algorithms in Java*^(TM)* Sixth Edition (pg 562, Chapter 12.4):

>Even so, merge-sort is an excellent algorithm for situations where the input is stratified across various levels of the computer’s memory hierarchy (e.g., cache, main memory, external memory). In these contexts, the way that merge-sort processes runs of data in long merge streams makes the best use of all the data brought as a block into a level of memory, thereby reducing the total number of memory transfers.

But what does it mean? I do not understand it. Also, what do the words in bold mean?

πŸ‘︎ 13
πŸ’¬︎
πŸ‘€︎ u/Kaushik2002
πŸ“…︎ Jan 22 2022
🚨︎ report
Does your average programmer actually know the answer to those interview type questions on top of their head, like how to do a merge sort from scratch with no googling?

I could with some google fu but on the spot in an interview probably not

πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Jan 15 2022
🚨︎ report
A solution for the factions to "merge", in a way that (sort of) makes sense with story

Take a leisurely scroll through this reddit and you see no end of posts regarding the horde/alliance imbalance, and offering reasons why it is important for Blizzard to merge the factions. I'll not repeat any of the reasoning other people have given as I would just be repeating what has already been said a billion times. Instead I come to offer a solution.

I will provide a TL;DR at the bottom.

Obligatory disclaimer: I am not saying this is the only, or best solution, this is just one solution I think would work.

One thing that should be said, for clarity, is that the biggest reason NOT to merge the factions is that the identity of the game revolves around the ongoing conflicts between the horde and the alliance. The game would become "world of peacecraft" if the factions were allied with eachother. This is what I hope to tackle.

The Core Concept

The easiest implimentation I can see to remedy this is to have conflicts between minor factions (hereon referred to as "MFs"), akin to the covenents. These MFs would be seperate from the main factions and players could choose which one to ally with and would have an impact on gameplay but would not restrict players from grouping up together in any non-PvP fashion. They could have different dailies, stories, and (some) content to make each of these factions feel unique and interesting in their own right, but having two sets of factions means that from a story perspective, PvE and PvP interests can be seperated. Long story short, Raids and Dungeons can be what the Horde and Alliance heroes are trying to achieve to save the world, or whatever, and then Battlegrounds and Warmode can be what the MFs are trying to achieve for their own gain.

Those who have played the recently released New World will see alot of similarities here. You'll have to take my word that I had this idea before New World was released, although having played New World and seen the model they use, I am sure that this model would fit beautifully into WoW.

I hope you can all see why this would be good for the main story of the game. Blizzard no longer has to write stories where the Horde and Alliance both have to have a reason to go into the same raids/dungeons but also write conflicts between them, as they are truly at peace or allied. They can then focus the conflict stories within the game entirely into the MFs.

Collaborative efforts - Horde/Alliance

Conflicting efforts - MFs

How I think this would benefit PvP primarily

This

... keep reading on reddit ➑

πŸ‘︎ 15
πŸ’¬︎
πŸ‘€︎ u/Stenzivore
πŸ“…︎ Dec 11 2021
🚨︎ report
Merge sort
πŸ‘︎ 548
πŸ’¬︎
πŸ‘€︎ u/zyxzevn
πŸ“…︎ Nov 15 2021
🚨︎ report
Merge sort with O(sqrt(n)) auxiliary memory complexity (and even less)

In this text an algorithm is described that merges two sorted arrays into one sorted array. Time complexity is O(n), auxiliary memory complexity is O(sqrt(n)), and stable. If this algorithm is used for merge sort, then resulting sorting algorithm will be stable, have O(nlog(n)) time complexity and have O(sqrt(n)) auxiliary memory (and even less for some cases).

I hope the reader knows how classical merge sort works. This knowledge is necessary to understand this text better; the described algorithm is a modification of array merging algorithm that is used as a part for merge sort.

The essential concept of this algorithm is to reuse memory that is being released during merging of sub-arrays A and B. And in order to handle that memory, array is divided into pages of equal size and page table is used. While any action with page – like filling, copying, moving, swapping – do updates of entries of the page table. Moving (copying, swapping) of pages means moving data in those pages – pages themselves are just coordinates and they keep their initial location.

Page is a piece of the array of fixed length, for example 1000 elements. Pages go one-by-one sequentially. A synonym for pages is sections.

Page table stores auixiliary page-related information. In the simplest implementation it is an array of integers; the length of that array equals to pages count.

Example run is available under Ref[4] in the bottom.

Now the description of the algorithm

  1. The function receives array or array interval that contains two sorted sub-arrays A ΠΈ B, temporary buffer 3 pages in size, page table, page size, and parameters that indicate boundary and size of sub-arrays A and B. Temporary buffer and page table are external towards algorithm and created before launching sorting.
  2. Divide array into pages (each page contains for example 1000 array elements). As a result array, pages, buffer and page table will look as below.

https://preview.redd.it/8nos1aermnu71.png?width=900&format=png&auto=webp&s=c0d90294eb8b0e96fa089995a65586e520751d4f

  1. Find a free page and perform merging of sub-arrays A and B in to that page until the page is filled or elements from sub-arrays A and B run out. After the page is filled do update in page table, specifically the page position where it would be in the finally sorted array, it means where to move the page later.

Merging is a process used in classical merge sort, it is performed by t

... keep reading on reddit ➑

πŸ‘︎ 91
πŸ’¬︎
πŸ‘€︎ u/Max_Arbuzov
πŸ“…︎ Oct 20 2021
🚨︎ report
Is there already a merge sort implementation available?

Or any other algorithm with similar big o I'm sorting vector2s by their .angle() and the default sort_custom() isn't fully sorting it

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Realfakesadboi
πŸ“…︎ Nov 26 2021
🚨︎ report
Constantly scared if i would be able to ever code, i have problems trying to solve algorithms like merge sort since i make mistakes like segmentation fault and it is very hard to find it. Will i be able to earn in a job, how can i atleast make basic finances coding. Im from a developing country.

Do jobs make you code a lot of algorithms, can i take help of internet. Is there a deadline to work. How does it work in offices? What are ways i can ensure to maintain my position at a job.

πŸ‘︎ 16
πŸ’¬︎
πŸ‘€︎ u/Phantom-coder
πŸ“…︎ Oct 17 2021
🚨︎ report
I present to you all: the one liner merge sort
πŸ‘︎ 1k
πŸ’¬︎
πŸ“…︎ Aug 07 2021
🚨︎ report
Could someone please explain the following function parameter in this implementation of a merge sort algorithm?

Hi,

I believe I understand most of the merge sort algorithm (top-down), but I can't figure out why one of the function parameters is what it is.

When calling merge_sort(array, 0, len(array) - 1) why is it len(array) - 1 and not just len(array)? If I change it to len(array) it provides the same result.

def merge_sort(array, left_index, right_index):
    if left_index >= right_index:
        return
    
    mid = (left_index + right_index)//2
    merge_sort(array, left_index, mid)
    merge_sort(array, mid + 1, right_index)
    merge(array, left_index, right_index, mid)

def merge(array, left_index, right_index, middle):
    # Make copies of both arrays
    left_copy = array[left_index:middle+1]
    right_copy = array[middle+1:right_index+1]

    # initial pointers for variables.
    left_copy_index = 0
    right_copy_index = 0
    sorted_index = left_index # sentinel value(?)

    # iterate both copies until no elements are left
    while left_copy_index < len(left_copy) and right_copy_index < len(right_copy):
        # If left_copy has a smaller element, sort it and increase pointer index by 1
        if left_copy[left_copy_index] <= right_copy[right_copy_index]:
            array[sorted_index] = left_copy[left_copy_index]
            left_copy_index += 1

        # Opposite of above
        else:
            array[sorted_index] = right_copy[right_copy_index]
            right_copy_index += 1

        # Regardless of where the element came from
        # move forward in the sorted part
        sorted_index += 1

    # for as long as left_copy has any items
    # check remaining elements and add them to array at sorted index
    while left_copy_index < len(left_copy):
        array[sorted_index] = left_copy[left_copy_index]
        # increase indices
        left_copy_index += 1
        sorted_index += 1

    # for as long as right_copy has any items
    # check remaining elements and add them
    while right_copy_index < len(right_copy):
        array[sorted_index] = right_copy[right_copy_index]
        # step forward
        right_copy_index += 1
        sorted_index += 1

array = [33, 42, 9, 37, 8, 47, 5, 29, 49, 31, 4, 48, 16, 22, 26]
merge_sort(array, 0, len(array) - 1)
print(array)

Thank you!

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/TheRealThrowAwayX
πŸ“…︎ Oct 19 2021
🚨︎ report
Need tips for doing programming math correctly with dyscalculia, Like i need to do iterations of merge sort on paper as test case before implementation and a single mistake either confuses me or destroys the entire tree structure i make in problems.

I just need tips to do it correctly. This group has kept me motivated enough to go through with programming. Also idk why i hate writing?

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/Phantom-coder
πŸ“…︎ Oct 11 2021
🚨︎ report
C++ Programming Interview - Part 6 ( Merge Sort Algorithm ) youtube.com/watch?v=u1oAp…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/codelikeme
πŸ“…︎ Dec 01 2021
🚨︎ report
Why is merge sort O(nlogn) instead of O(n2^n)

I know it's been proven but I'm curious and I want to dispel any doubts I have. Every time we split, aren't we creating two more subproblems so for every level we would have 2^n subproblems?

Also what would be an easy example of a problem with a big O of 2^n?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/2kfan
πŸ“…︎ Nov 02 2021
🚨︎ report
C++ Programming Interview - Part 6 ( Merge Sort Algorithm ) youtube.com/watch?v=zeD2K…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/codelikeme
πŸ“…︎ Nov 27 2021
🚨︎ report
distMergeSort: Distributed merge sort for large sets across nodes in a network github.com/el10savio/dist…
πŸ‘︎ 23
πŸ’¬︎
πŸ‘€︎ u/el10savio
πŸ“…︎ Nov 03 2021
🚨︎ report
Are these two algorithms are really important. (Rabin Karp algorithm and KMP pattern searching algorithm). They both are twice the size of merge sort and quick sort.

(Rabin Karp algorithm and KMP pattern searching algorithm). They both are twice the size of merge sort and quicksort. I just want to skip them. Can anyone share their views ?? Should I skip them because they are taking a lot of memory in my brain cellsπŸ˜….

πŸ‘︎ 18
πŸ’¬︎
πŸ‘€︎ u/GreatRitesh
πŸ“…︎ Sep 02 2021
🚨︎ report
Issues while creating a merge sort algorithm

I'm trying to create a merge sort algorithm and there are two issue that I'm facing with my code.

First that I want to create the tempL and tempR array of n1+1 and n2+1 size but it wont let me saying the the expression needs to be constant and second where a value of type "int*" cannot be assigned to an entity of type "int" where ever im trying the assign the value of tempL or tempR to any onther expression.Can someone explain these issues to me?

I followed a guide on the internet on how to create dynamic arrays hence the part:

int** tempL = new int* [n1 + 1];
int** tempR = new int* [n2 + 1];

But using this thing gives errors when trying to assign values to other expression give the error "a value of type "int*" cannot be assigned to an entity of type "int"".

#include <iostream>
#include <algorithm>
using namespace std;

void MergeSort(int arr[], int p, int r) {
	int q = 0;
	for (int i = p; i <= r; i++) {
		if (p >= r) {
			return; //Check
		}
		else {
			q = (p + r) / 2;
			MergeSort(arr, p, q);
			MergeSort(arr, q + 1, r);
			Combine(arr, p, q, r);
		}
	}
}

void Combine(int arr[], int p, int q, int r) {
	int n1, n2; n1 = n2 = 0;
	int a, b;
	
	n1 = q - p + 1;
	n2 = r - q;

	//int tempL[n1 + 1]; // cant assign value
	//int tempR[n2 + 1]; // cant assign value

	int** tempL = new int* [n1 + 1];
	int** tempR = new int* [n2 + 1];

	int a = 0;
	for (int b = p; b <= q; b++) {
		tempL[a] = arr[b];
		a++;
	}

	for (int b = (q+1); b <= r; b++) {
		tempR[a] = arr[b];
		b++;
	}

	int x = (max(tempL[n1 - 1], tempR[n2 - 1]) + 1);
	tempL[n1] = x; tempR[n2] = x;

	int i, j;
	i = j = 0;

	for (int k = p; k <= r; k++) {
		if (tempL[i] < tempR[j]) {
			//print: filling index k with L[i] from left
			arr[k] = tempL[i];
			i++;
		}
		else {
			//print: fill	ing index k with R[j] from right
			arr[k] = tempR[j];
			j++;
		}
	}
}

int main() {
	int rollNumber[6] = { 1, 9, 0, 9, 0, 2 };
	MergeSort(rollNumber, 1, 6);
	return 0;
}
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/an-unknownentity
πŸ“…︎ Oct 11 2021
🚨︎ report
Merge Sort: IT LIVES!

So today I wanted to try and code all the sorting/searching algorithms myself. Selection/bubble were simple enough... but merge sort? I've been coding for 6h straight and JUST now got it to work. What took me the most was planning out how the program would work (I have 3 sheets of paper filled with scribbles).

Might not be the most efficient or clean (I would highly appreciate tips and corrections!), but damn do I feel super proud! Decided I would only have the short as a guide, and tried to hardcore as little as possible: I get the unsorted arrey(size and content) from user input and print it out sorted. Also wrote plenty comments so I understand what I did if I ever want to come back to it and improve it.

#import <cs50.h>
#import <stdio.h>
void mergesort(int lenght, int arrey[]);
void join(int sortedarrey[], int rLenght, int rightarrey[], int lLenght, int leftarrey[]);

int main(void)
{
    //Get arrey of ints from input
    int arreylenght = get_int("Desired size of int arrey: ");
    int numbers[arreylenght];
    for(int i  = 0; i < arreylenght; i++)
    {
        numbers[i] = get_int("%iΒ° arrey number: ", i+1);
    }
    //sort arrey by using merge sort
    mergesort(arreylenght, numbers);
    
    //print sorted arrey
    printf("Sorted Arrey: \n");
    for(int i = 0; i < arreylenght; i++)
    {
        printf("%i ", numbers[i]);
    }
    printf("\n");
}

void mergesort(int lenght, int arrey[])
{
    //base case:
    if(lenght == 1)
    {
        return;
    }
    
    //initializing and populating right arrey:
    int rArreyLen = (lenght/2);
    int rArrey[rArreyLen];
    for(int i = 0; i < rArreyLen; i++)
    {
        rArrey[i] = arrey[i];
    }

    //initializing and populating left arrey:
    int lArreyLen = lenght - rArreyLen;
    int lArrey[lArreyLen];
    for(int i = 0; i < lArreyLen; i++)
    {
        lArrey[i] = arrey[(rArreyLen)+i];
    }
    
    //invoking join()
    join(arrey, rArreyLen, rArrey, lArreyLen, lArrey);
}


void join(int sortedarrey[], int rLenght, int rightarrey[], int lLenght, int leftarrey[])
{
    mergesort(rLenght, rightarrey);
    mergesort(lLenght, leftarrey);
    int rightcou
... keep reading on reddit ➑

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Quiver21
πŸ“…︎ Oct 08 2021
🚨︎ report
Rust Merge Sort

I tried my hand at implementing merge sort in Rust. The program compiles without errors, however the resultant array is not sorted. I would like to know where I went wrong and also my code may not be clean. I would be happy if I got suggestions for that as well.

Thank you in advance.

fn merge(mut vec: Vec<i32>) -> Vec<i32> {
    if vec.len() > 1 {
        let mid = vec.len() / 2;

        let l = vec[..mid].to_vec();
        let r = vec[mid..].to_vec();

        merge(l.to_vec());
        merge(r.to_vec());

        let (mut i, mut j, mut k) = (0, 0, 0);

        while i < l.len() && j < r.len() {
            if l[i] < r[j] {
                vec[k] = l[i];
                i += 1;
            } else {
                vec[k] = r[j];
                j += 1;
            }
            k += 1;
        }

        while i < l.len() {
            vec[k] = l[i];
            i += 1;
            k += 1;
        }

        while j < r.len() {
            vec[k] = r[j];
            j += 1;
            k += 1;
        }
    }
    vec
    // println!("Vec: {:?}", vec);
}

fn main() {
    let arr: Vec<i32> = vec[12, 11, 13, 5, 6, 7];
    // let mid = arr.len() / 2;
    println!("Sorted Array: {:?}", merge(arr));
    // println!("last: {}", arr[arr.len() - 1]);

    // println!("L: {:?}", &arr[mid..]);
}
πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Sep 07 2021
🚨︎ report
Implementing merge sort with vectors

Hi everyone, so I took some merge sort code from the comment at the top of the program and I'm trying to implement it using vectors. I tried to change a lot of components but the sorting isn't happening. For the moment I can't seem to see where the problem is so I'm hoping a fresh set of eyes can guide me to the problem.

in terms of inputs, first you have to enter the amount of numbers to be sorted. After pressing enter, you then enter the numbers to be sorted

Here's a screenshot of a sample input

Here is my code

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/2kfan
πŸ“…︎ Oct 12 2021
🚨︎ report
Getting difference between max and min numbers in each merge process in merge sort

Hi everyone, so the following is the program I have so far with a few debug statements in the merge function.

Here is a rough drawing of what Im trying to do. The sum of the total differences are represented by the variable "candies". My code seems to make sense(?) so idk what to change

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/2kfan
πŸ“…︎ Oct 10 2021
🚨︎ report
Announcing the v0.4 of grenad: A library that provides tools to sort, merge, write, and read immutable key-value pairs github.com/Kerollmops/gre…
πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/Kerollmops
πŸ“…︎ Oct 12 2021
🚨︎ report
RISC-V merge sort implementation
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/WheyPr0tein
πŸ“…︎ Oct 04 2021
🚨︎ report
Programming merge sort algorithm in C++. Not sure where wrong, getting wrong output. Anyhelp?
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/KDivyanshu
πŸ“…︎ Oct 17 2021
🚨︎ report
Hybrid insertion and merge sort?

I am trying to implement a hybrid of mergesort and insertion sort. When the subarray size reaches below a threshold, it should switch to insertion sort. However I tried with a bunch of array of different length and different threshold (K) amount, and most of the time there isn't any noticeable difference, other than just a 2-3 lesser comparisons. I was told that switching to insertion sort for smaller sized array would help greatly.

Am I doing it wrong?

#include <iostream>


int comparisons = 0;
int swaps = 0;

void mergesort(int x[], int l, int r);

void insertionSort(int x[],int start, int end);

int K = 5;
int main() {
  int x[] = {716, 526, 412, 893, 718, 1000, 913, 643, 937, 550, 363, 472, 920, 802, 810, 898, 894, 978, 326, 420, 463, 644, 19, 817, 947, 625, 524, 602, 873, 569, 562, 219, 645, 122, 91, 739, 206, 881, 793, 356, 922, 940, 172, 631, 346, 923, 728, 515, 605, 239, 549, 229, 195, 653, 901, 357, 882, 883, 539, 210, 862, 193, 767, 502, 647, 542, 735, 110, 272, 388, 545, 202, 897, 205, 639, 633, 933, 582, 348, 428, 642, 191, 199, 58, 343, 546, 505, 276, 719, 501, 21, 445, 444, 62, 217, 949, 35, 664, 273, 841, 18, 141, 295, 597, 511, 509, 806, 560, 211, 945, 811, 290, 382, 359, 196, 829, 870, 827, 896, 465, 673, 274, 832, 287, 13, 604, 333, 848, 658, 731, 512, 500, 577, 864, 751, 638, 158, 129, 722, 406, 252, 114, 813, 608, 266, 443, 387, 948, 259, 544, 383, 48, 232, 541, 77, 322, 931, 819, 682, 696, 998, 292, 342, 297, 140, 503, 180, 26, 57, 474, 693, 176, 175, 5, 254, 438, 784, 102, 868, 119, 772, 23, 794, 532, 281, 548, 866, 588, 354, 160, 741, 871, 723, 269, 659, 3, 135, 395, 416, 351, 98, 153, 87, 61, 764, 594, 656, 223, 565, 709, 436, 655, 833, 803, 840, 986, 918, 516, 950, 970, 606, 989, 773, 271, 4, 168, 235, 779, 242, 558, 433, 452, 536, 358, 381, 470, 884, 337, 895, 830, 31, 431, 79, 296, 362, 213, 109, 963, 285, 453, 613, 589, 105, 774, 649, 204, 478, 52, 861, 324, 368, 317, 320, 590, 201, 506, 721, 939, 300, 278, 676, 713, 283, 919, 904, 746, 227, 486, 761, 230, 994, 394, 234, 24, 418, 9, 146, 97, 564, 537, 749, 117, 705, 755, 903, 691, 115, 145, 127, 370, 417, 34, 208, 365, 138, 96, 706, 113, 640, 424, 902, 163, 151, 253, 268, 410, 280, 149, 154, 491, 409, 790, 448, 697, 93, 144, 467, 216, 76, 286, 192, 442, 614, 226, 907, 805, 15, 347, 629, 490, 435, 801, 284, 576, 612, 592, 166, 899, 189, 628, 781, 996, 523, 468, 734, 938, 796, 744, 408, 142, 878, 449, 299, 279, 7
... keep reading on reddit ➑

πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/cocag13996
πŸ“…︎ Aug 28 2021
🚨︎ report
If I am implementing a hybrid merge insertion sort for inputs up to 50,000-100,000 what should i pick for a threshold?

If insertion works well for small arrays should I pick like 40? I mean maybe 100 seems better but at 100 merge sort is better than insertion sort. Thank you for any advice.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Lawliet66
πŸ“…︎ Sep 19 2021
🚨︎ report
Merge sort with O(sqrt(n)) auxiliary memory complexity – example run

It is an example run for array merge algorithm described here: https://www.reddit.com/r/compsci/comments/qc95r7/merge_sort_with_osqrtn_auxiliary_memory/. Using that algorithm will allow to create Mergesort-based algorithm with O(sqrt(n)) additional memory usage.

The algorithm recieves two sorted sub-arrays and returns one sorted array that contains elements from sub-arrays.

The input sub-arrays and a temporary buffer:

https://preview.redd.it/s0443fqpe7v71.png?width=721&format=png&auto=webp&s=6c765dec0943388a46447f38783e78670d2797a5

Virtually divide the array and the buffer into pages (or sections):

https://preview.redd.it/2i32t6rse7v71.png?width=837&format=png&auto=webp&s=8308eada46fd4fc8dfa2a98ac6a6bcc2e4909b6c

Stage 1. Merge array elements into pages (pre-merging)

Definition: "Page" is a piece of the array. The synonym is "section". All pages have the same size (length) and they go sequentially without gaps or overlapping.

Definition: "Merge into a page" means to select the minimal element in sub-arrays A and B, extract (remove) it and add it into the page. And repeat this step until the page is filled or there are no more elements in A and B. To find the minimal element use the fact that both sub-arrays are sorted.

Definition: "Sequence number" or order number shows when page has been filled or the filling order, e.g. 1st, 2nd, 3rd, 4th etc. Each page will have its own sequence number after it is filled. Sequence numbers are stored in auxiliary memory.

Step 1.1. Merge into bufpage_1. This page is the 1st to be filled, so its sequence number is 1. Store the sequence number somewhere. The step and its result are below:

Step 1.1

Step 1.2. Merge into bufpage_2. This page is the 2nd to be filled, so its sequence number is 2. Store the sequence number somewhere. The step and its result are below:

Step 1.2

Step 1.3. page_1 became free. Merge into page_1. This page is the 3rd to be filled, so its sequence number is 3. Store the sequence number somewhere. The step and its result are below:

[Step 1.3](https://preview.redd.

... keep reading on reddit ➑

πŸ‘︎ 47
πŸ’¬︎
πŸ‘€︎ u/Max_Arbuzov
πŸ“…︎ Oct 23 2021
🚨︎ report
Why is the time complexity of merge sort nlogn and not n+logn

Why are we multiplying n and logn , the way I understand is log n is the number of times division occurs and n is for merging process.

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/cyberwarrior861
πŸ“…︎ Sep 15 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.