Pergunta de entrevista da empresa Amazon

You have two sorted arrays - how can you effectively merge them into one giant sorted array?

Respostas da entrevista

Sigiloso

6 de jul. de 2011

Mergesort works, but you don't need to use it in this case. Since the two lists are already sorted, just iterate through them both at the same time, appending the next-highest element from the two lists into a new list. O(n+m) time.

1

Sigiloso

29 de set. de 2011

Merge procedure from Mergesort. explanation in cormen

Sigiloso

22 de mar. de 2011

Merge sort works using the principle that if you have two sorted lists, you can merge them together to form another sorted list. Consequently, sorting a large list can be thought of as a problem of sorting two smaller lists and then merging those two lists together. Merge sort guaranties O(nlog(n))