Hello guys I was learning about the merge sort so I wrote this function that takes 2 arrays and merges them sorted. Can someone tell me the time complexity of this function? I thought it would be O(n^2) as I am using shift inside a while loop. Is that correct or am I missing something here? Answer The worst case
Tag: big-o
How to sort two sorted arrays without using sort methods (sort) nor sort algorithms (bubble sort, quick sort)
I was asked in an interview and my answer was similar to this, which is wrong due to the final loop. Answer What you are talking about — “sorting” two arrays that are each themselves already sorted — is called a merge. This is how you do that: