I'm trying to merge to sorted arrays into a third sorted array , but I can't see
any way to do that in O(n)
, only in O(n*n)
.Am I wrong ? is there a way to do that in O(n)
?
Edit :
Actually the question is a little different :
I have 2 sorted skip lists and I want to merge them into a new sorted skip list ,without changing
the input (i.e. the two skip lists) .
I was thinking about :
put the lists in two arrays
merge the two arrays using MergeSort (this takes O(n)
runtime)
build a new skip list from the sorted array .... // I'm not sure about its runtime
any ideas ?
Regards
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…